Last active
December 17, 2015 09:49
-
-
Save tatsuyaueda/5590181 to your computer and use it in GitHub Desktop.
jQueryMobile Dynamic Content Rewrite(1)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(document).bind("pagebeforechange", function(e, data) { | |
if(typeof data.toPage === "string") { | |
var u = $.mobile.path.parseUrl(data.toPage); | |
var re = /^#pageID/; | |
if (u.hash.search(re) !== -1) { | |
$.get("/foo/path", function(data) { | |
var $page = $("#pageID"); | |
var $content = $page.children( ":jqmData(role=content)" ); | |
$content.html($("<div>" + data + "</div>").children("#pageID").children( ":jqmData(role=content)" ).children()).trigger( "create" ); | |
$content.find( ":jqmData(role=listview)" ).listview(); | |
//$page.page(); | |
$.mobile.changePage($page, data.options); | |
e.preventDefault(); | |
}); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment