Skip to content

Instantly share code, notes, and snippets.

@asadawan
Created July 26, 2011 06:53
Show Gist options
  • Save asadawan/1106154 to your computer and use it in GitHub Desktop.
Save asadawan/1106154 to your computer and use it in GitHub Desktop.
Hack to override the the changePage handler in jQuery Mobile, so data can be passed to the "page" using a "__" in the data-url and appending the data to be passed after this delimiter. The nice part of this is that the resulting url can be used to bookmar
// Copyright: Asad Awan
// license: Apache
var utils: {
overrideChangePage: function() {
var cp = $.mobile.changePage;
$.mobile.changePage = function(url, opts) {
if (typeof(url) == 'string') {
var o = url.split('#');
if (o.length == 2) {
var base = o[0];
var s = o[1].split('__');
if (s.length == 2) {
utils.globalData = s[1];
url = base + '#' + s[0];
}
}
}
cp(url, opts);
};
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment