jquery-archive / jquery-mobile

jQuery Mobile Framework
https://jquerymobile.com
Other
9.69k stars 2.4k forks source link

JQM - Dynamic Listview to Details page not working #2473

Closed oluwaseye closed 13 years ago

oluwaseye commented 13 years ago

I want to display the content of the list on a page, that is by its id, the new page should display the data of the list that was clicked on.

heres what i have so far, it only lists but the link is not working..

Please i need help on this

  $('#seyzListPage').live('pageshow', function(){
        $.ajax({
         url: "data.php",
         dataType: 'json',

            success: function(json_results){
            listItems = $('#seyzList').find('ul');
            $.each(json_results.rows, function(key) {
               html = '<li <h3><a href="index1.html?id=' + [json_results.rows[key].airp_id] +'"rel="external">'+json_results.rows[key].airport_code+'</h3>';
              html += '<p><br> Aiport name: '+json_results.rows[key].airport_name+'</p></a></li>';

            listItems.append(html);
            });
            // Need to refresh list after AJAX call
              $('#seyzList ul').listview('refresh');
     $.mobile.pageLoading(true);     
        }
    });
});
cjblomqvist commented 13 years ago

A couple of examples of what is wrong with the above:

Foremost however, the biggest concern I have with the code is why would you want to do an ajax-call right after pageshow?? A better approach would be to make data.php a separate page that already consist of a the complete page, with head, body, header, footer, everything, and then do a regular call. If you need to trigger it through JavaScript, do it through the $.mobile.changePage (fully documented at http://jquerymobile.com/demos/1.0b3/docs/api/methods.html). Most likely you could do it through a regular link.

A working example of what you are trying to achieve (minus the ajax-functionality) can be found here: http://jsfiddle.net/cjblomqvist/8WU39/

Also, this is not really the place to ask for help regarding problems you have not being able to implement your own code. Please try to file these types of issues/questions in the forum instead: http://forum.jquery.com/jquery-mobile

I hope I didn't sound too rude with my comments and I wish you the best of luck with your further development with jQueryMobile.

Admins/Seyz4all: Please close this issue.

oluwaseye commented 13 years ago

thanks for the response. i am sorry for this... my code already lists but i need it to show the content of the list when clicked on another page...

you dont sound rude. its just that i couldnt get help on this at the jq forum.

cjblomqvist commented 13 years ago

Good :) No problems, we all do mistakes and sometimes we really need get something fixed quick.

Anyway, please close the issue too, you can find the "Close Issue" -button in the top right corner of the comment-box (only creators and admins of issues can close them, otherwise I'd close it myself).

toddparker commented 13 years ago

Sounds like I can close this...

oluwaseye commented 13 years ago

toddparker thats so unfair... am kinda takin dis personal.. u guys didnt even give any pointers..especially u todd.. dissapointed

toddparker commented 13 years ago

What? @cjblomqvist gave you a lot of help and said this could be closed. This isn't a support forum, it's a big tracker. If you have a concise test case on jsbin or jsfiddle that isolates an issue, we can re-open.