Solved

Jquery get value dropdownlist

Posted on 2013-12-12
2
326 Views
Last Modified: 2013-12-12
  $(window).load(function () {
        $(function () {
            $.getJSON('@Url.Action("List", "Search")', function (result) {
                 var ddl = $('#ID');
                 ddl.empty();
                 $(result).each(function (i, item) {

                     ddl.append(
                         $('<option/>', {
                             value: this.ID
                         }).html(this.Description)

                     );
                 });
            });
          

         });

Open in new window

I am using Jquery mobile. When I first go to the page the data loads, When I click a button and leave the page then come back I see the data in my Dom but it does not load back into the dropdown. anyway to fix this.
0
Comment
Question by:sevensnake77
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 39715760
Take a look here : http://jquerymobile.com/demos/1.2.1/docs/api/events.html

So try this :
 $(document).bind('pageinit', function() {


     $.getJSON('@Url.Action("List", "Search")', function (result) {
                 var ddl = $('#ID');
                 ddl.empty();
                 $(result).each(function (i, item) {

                     ddl.append(
                         $('<option/>', {
                             value: this.ID
                         }).html(this.Description)

                     );
                 });
            });


 });

Open in new window

0
 
LVL 9

Author Closing Comment

by:sevensnake77
ID: 39715778
Great thanks
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Requirements JQuery 1.6+ HTML CSS Introduction This article was inspired by an EE question (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28372511.html) on how to make a page show some balloons animate up a page…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question