2

So i have this two views :

1.viewarea.scala.html

@(name:String, tags:String, id:String)
@Main("Area") {
....
<ul id="areaFeat">

//the ul that I want to fill

</ul>
</div>
}

2.areaDescription.scala.html

@(id:String)
@Main("Description Area"){

    <form action="@routes.Application.PostAreaDescription(id)" method="POST">
            <textarea cols="40" rows="5" class="form-control" name="textarea"></textarea>
            <input type="submit" id="postDescArea">
    </form>

    <script>

    $(document).ready(function(){
    $('#postDescArea').click(function(){

      alert("clicked...");

      $("#areaFeat").append('<li><a href="@routes.Application.viewDescription(id)">Description</a></li>');

            });
        });

    </script>
}

I just want that li element to be added to the ul (from the first view) when that button is pushed.
My alert goes on ... but I can't append the li ... I do not know what I am doin' wrong ... Can someone please help ?
Thank you !

flori
  • 428
  • 1
  • 6
  • 22

1 Answers1

0

I do not know what I am doin' wrong?

viewarea.scala.html and areaDescription.scala.html are different page(as you dint include viewarea in areaDescription).You are calling ul tag id which is on other page. To confirm you can also check your browser console.Also check is it use JavaScript in one document to change HTML in another?

Community
  • 1
  • 1
singhakash
  • 7,891
  • 6
  • 31
  • 65
  • I know that ... Is there a way to put that li to that ul? I will try to put my script in the Main view, maybe then it will work ... – flori Feb 26 '15 at 14:32
  • @flori did you put both form and script in main? – singhakash Feb 26 '15 at 15:33
  • I have imported the script in Main and these pages are using the @Main template ... – flori Feb 26 '15 at 15:37
  • @flori but they are different document you cant do that see http://stackoverflow.com/questions/7493689/is-it-possible-to-use-javascript-in-one-document-to-change-html-in-another – singhakash Feb 26 '15 at 15:41
  • ok, I understand ... thank you.... i hoped i can ... ! I have some id's there ... so i can not put them in the same document. I will think at something else. – flori Feb 26 '15 at 15:55