I have a jQuery Mobile project that is distributed in different files, for example.
<!DOCTYPE html> <html> <head> <script type="text/javascript" charset="utf-8" src="cordova-2.3.0.js"></script> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" /> <link rel="stylesheet" href="css/custom.css" /> <script src="http://code.jquery.com/jquery-1.8.3.min.js"></script> <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script> <script src="js/methods.js"></script> </head> <body> <div data-role="page" id="firstPage"> <div data-role="header" data-position="fixed"> <h1>Header 1</h1> ... </div> <div data-role="content"> ... </div> </div> </body> </html> secondPage.html <!DOCTYPE html> <html> <head> <script type="text/javascript" charset="utf-8" src="cordova-2.3.0.js"></script> <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" /> <link rel="stylesheet" href="css/custom.css" /> <script src="http://code.jquery.com/jquery-1.8.3.min.js"></script> <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script> <script src="js/methods.js"></script> </head> <body> <div data-role="page" id="pageTwo" class="ui-page"> <div data-role="header" data-position="fixed" id="terminDetailSeiteHeader"> <h1>Header 2</h1> </div> <div data-role="content"> <div id="contentToFillWithDynamicListView"></div> </div> </div> </body> </html>
Then I got a script that should make a call to php-Script and create a list:
function listViewCreation() { var url = 'http://www.myServer.com/myPhp.php?someParameters=1&callback=?'; $.getJSON(url, function(data) { $('#contentToFillWithDynamicListView').empty(); var collapsibleList = '<ul data-role="listview">'; var myselfIsIncluded = 0; $.each(data, function(key, value) { collapsibleList += '<li>' + value['displayName'] + '</li>'; }); collapsibleList += '</ul>'; $('#contentToFillWithDynamicListView').html(collapsibleList).trigger('create'); }); }
..trigger ('create') leads to an error ... what am I missing?
EDIT 1
listViewCreation is named as follows:
$("#pageTwo").live("pageshow", function(e, data){ listViewCreation(); });
EDIT 2 I get deleted data from another server, which seems to be causing the error; but I donβt know how to solve it ... I collect data on both pages (1 and 2); for the first page it works, for the second it doesnβt ...
$.getJSON(url, function(data) { ... }
source share