JQM 1.3 panel + iscrollview + dynamically loaded pages
Hi all,
I'm trying to implement a listview that has data-iscroll enabled where pages are loaded dynamically on pageinit.
I currently have 2 external pages where there is a listview with data-iscroll set and on pageinit; one page get's loaded into the index.html's content and the other to a panel.
Basically; it's like this for my index.html page:
- <html>
- <head>
- <meta charset="utf-8" />
- <meta name="viewport" content="width=device-width, initial-scale=1" />
-
- <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0-beta.1/jquery.mobile-1.3.0-beta.1.min.css" />
-
- <script src="http://code.jquery.com/jquery-1.8.3.min.js"></script>
- <script src="http://code.jquery.com/mobile/1.3.0-beta.1/jquery.mobile-1.3.0-beta.1.min.js"></script>
-
- <script src="iscroll.js" type="text/javascript"></script>
- <script src="jquery.mobile.iscrollview.js" type="text/javascript"></script>
-
- <script type="text/javascript" charset="utf-8" src="my.js"></script>
- </head>
- <body>
- <div data-role="page">
- <div id="mainPageWrapper">
- <div data-role="content" id="content">
- <!-- dynamically inserted listview goes here -->
- </div><!-- content -->
- </div><!-- mainPageWrapper -->
-
- <div data-role="panel" id="sidePanel" data-position="right" data-display="overlay">
- <!-- dynamically inserted listview goes here -->
- </div><!-- sidePanel -->
-
- </div><!-- page -->
- </body>
- </html>
I then have 2 separate HTML pages that consists of the same thing except for the listview ID:
listviewPage1.html has the listview ID of listview1
listviewPage2.html has the listview ID of listview2
- <html>
- <body>
- <div id="listviewPage1Wrapper">
- <ul data-role="listview" data-iscroll="scroller" id="listview1">
- ...lots of data goes here...
- </ul>
- </div><!-- wrapper -->
- </body>
- </html>
Javascript code (
my.js):
- $(document).live('pageinit', function(){
- loadPages('content', 'listviewPage1.html');
- loadPages('sidePanel', 'listviewPage2.html');
- }
-
- function loadPages(loadToDivID, pageToLoad){
- $("#"+ loadToDivID).empty();
-
- $.get(pageToLoad, function(data) {
- var $tempElement = $(data).appendTo($('#' + loadToDivID));
- $tempElement.trigger('create');
- });
- }
All libraries are also properly included and I know this because when I have the listviews directly in the content and side panel; they work perfectly.
Does anyone know what I'm doing wrong and how to fix it?
Thanks.