call jquery changePage() on localStorage

kjk

New Member
I have a simple jquery mobile page:\[code\]<!DOCTYPE html><html><head> <meta name="viewport" content="width=device-width, initial-scale=1.2"> <link rel="stylesheet" href="http://stackoverflow.com/questions/14532636/js/jquery.mobile-1.2.0.css" /> <script src="http://stackoverflow.com/questions/14532636/js/jquery-1.8.2.js"></script> <script src="http://stackoverflow.com/questions/14532636/js/jquery.mobile-1.2.0.js"></script></head> <body> <div id="MyContainer"> <!-- ##################### Raw Part ##################### --> <div data-role="page"> <div data-role="header"> <h1> Hello World </h1> </div> </div> </div> </body></html>\[/code\]when I execute that page it renders fine with a black header and title.The reason why that page loads correctly is because jquery-mobile placed new attributes where needed in fact the innerHTML of MyContainer after the page loads is:\[code\]<!-- ##################### Parsed Part ##################### --><div data-role="page" data-url="/jqueryMobile/TC_Page/main2.html" tabindex="0" class="ui-page ui-body-c ui-page-active" style="min-height: 1464px;"> <div data-role="header" class="ui-header ui-bar-a" role="banner"> <h1 class="ui-title" role="heading" aria-level="1"> Hello World </h1> </div></div>\[/code\]In other words the Raw Part turn into the Parsed Part . I will like to know what jquery.mobile function made the conversion from the Raw Part to the Parsed Part!The functions \[code\]$.mobile.changePage()\[/code\], \[code\]$.mobile.loadPage()\[/code\] enables me to do that For example I could do:\[code\]// place response from SomeUrl inside the div MyContainer and convert it from raw to parsed!$.mobile.loadPage('SomeUrl', { pageContainer: $('#MyContainer') });// later then get the child child (note second child) of MyContainer and make that the child of MyContainer\[/code\]The problem now is:All those functions: loadPage, ChangePage etc make an ajax call. What if I already have the html that I want to inject ( I have it in webBrowser local storage or in a Cookie)! In other words how can I make this work:\[code\]<!DOCTYPE html><html><head> <meta name="viewport" content="width=device-width, initial-scale=1.2"> <link rel="stylesheet" href="http://stackoverflow.com/questions/14532636/js/jquery.mobile-1.2.0.css" /> <script src="http://stackoverflow.com/questions/14532636/js/jquery-1.8.2.js"></script> <script src="http://stackoverflow.com/questions/14532636/js/jquery.mobile-1.2.0.js"></script></head> <body> <div id="MyContainer"> </div> <script> function SomeFunction(){ var someHTML = localStorate.html1; // html1 = raw part = <div data-role="page"><div data-role="header"><h1> Hello World </h1></div></div> $("#MyContainer").html(someHTML); // now here I am stuck!!!!!!!!!!!!!!! // how can I make the content of MyContainer go from the raw part to the Parsed Part! // I am looking for something like: $JqueryMobile.ParseHTML($("#MyContainer")); } </script> </body></html>\[/code\]
 
Back
Top