Skip to content

Instantly share code, notes, and snippets.

@rtekie
Created August 26, 2012 19:52
Show Gist options
  • Save rtekie/3483098 to your computer and use it in GitHub Desktop.
Save rtekie/3483098 to your computer and use it in GitHub Desktop.
// Listen for any attempts to call changePage().
$(document).bind( "pagebeforechange", function(e, data) {
// We only want to handle changePage() calls where the caller is asking us to load a page by URL.
if (typeof data.toPage === "string") {
// We only want to handle a subset of URLs.
var u = $.mobile.path.parseUrl(data.toPage);
var home = /^#home/;
var qrcode = /^#qrcode/;
if (u.hash.search(home) !== -1) {
// Display a list of URLs.
showUrlList(u, data.options);
e.preventDefault();
}
else if (u.hash.search(qrcode) !== -1) {
// Display QR code for the selected URL.
showQRCode(u, data.options);
e.preventDefault();
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment