Skip to content

Instantly share code, notes, and snippets.

@TerryMooreII
Last active December 20, 2015 07:09
Show Gist options
  • Save TerryMooreII/6091136 to your computer and use it in GitHub Desktop.
Save TerryMooreII/6091136 to your computer and use it in GitHub Desktop.
Jquery mobile. Pass data from hashtag page links with in jquery mobile Ex #newPage?key=value&key2=asdf. This is by no means a final product but it gets the job done.
var params;
// Listen for any attempts to call changePage().
$(document).bind( "pagebeforechange", function( e, data ) {
if ( typeof data.toPage === "string" ) {
var u = $.mobile.path.parseUrl( data.toPage );
var re = /^#/;
var question = u.hash.indexOf('?');
if ( u.hash.search(re) !== -1 && question !== -1 )
params = parseParams(u.hash.substring( question + 1 ));
}
});
var parseParams = function(params){
var ret = [];
var p = params.split('&');
console.log(p)
for (var i=0; i<p.length; i++){
var param = p[i].split('=');
var a = [];
ret[param[0]] = param[1];
}
return ret;
}
var isParamsEmpty = function(){
return params === null || params === undefined;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment