Is it possible to insert page divs into jQuery mobile page using append()? -


in order load jquery mobile page using anchor tag, 1 gives page div's id href

<a href="#page2">my link</a> <div data-role="page" id="page2">     <div data-role="header"></div>     <div data-role="page"></div>     <div data-role="footer"></div> </div> 

but assumes page div loaded dom. if want generate pages , put them dom so:

$("body").append(newpagedivhtmlstring); 

i trying keep getting "cannot call method _trigger of undefined".

stepping through jquery mobile (beta 1) source code, found on line 2600 following code:

page = settings.pagecontainer.children( ":jqmdata(url='" + dataurl + "')" ); 

where pagecontainer html body element , dataurl page div's id. computes undefined , seems source of problem. possible insert page div jquery mobile page, in manner am?

thanks reading long question. :)

i tested on local machine , works me:

<html> <head>  <link rel="stylesheet" href="http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.css" />  <script src="http://code.jquery.com/jquery-1.6.1.min.js"></script>  <script src="http://code.jquery.com/mobile/1.0b1/jquery.mobile-1.0b1.min.js"></script>  <script>  function create_page(page_name) {     $('body').append('<div data-role="page" id="' + page_name + '"><div data-role="content">some content in here.</div></div>');     //edited out, see below $.mobile.changepage($('#' + page_name)); }  </script> </head> <body>    <div data-role="page"> <div data-role="content"> <a href="javascript:create_page('test_page_name');" data-role="button" style="padding:15px; font-size:30px;">test text</a> </div> </div>  </body> </html> 

----edit---- have function:

function change_page(page_name) {    $.mobile.changepage($('#' + page_name)); } 

and use change dynamically created pages so:

<a href="javascript:change_page('test_page_name');" data-role="button" style="padding:15px; font-size:30px;">change page</a> 

there strange behavior trying link dynamically created page using hash (href="#test_page_name"). in firebug saw create page function appended new page onto body, change page button create page same id original page data-url set properly. data-role=page div created clicking on change page link had same content first div, , page created create_page function ignored.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -