Reputation: 9378
I have looked at this post Here and it looks like a simple way of getting a querystring, but Is there a easy way of doing this with the jquery mobile framework? thanks for any advice
#MobileHomePage?param1=data¶m2=data1
Upvotes: 1
Views: 2478
Reputation: 1040
make a jquery plugin for this.
(function( $ ){
$.fn.queryStrings = function( string ) {
var url = /[^?]*$/.exec(window.location.href)[0].split('&');
var obj = {};
url.forEach(function(url) {
var tup = url.split('=');
obj[tup[0]] = tup[1];
});
if (string) return obj[string];
return obj;
};
})( jQuery );
use like this:
$().queryStrings('myparam')
or
$().queryStrings()
to return all
Upvotes: 0
Reputation: 1640
Passing data between pages with jQuery Mobile is very simple just use this function
$.urlParam = function(name){
var results = new RegExp('[\\?&]' + name + '=([^&#]*)').exec(window.location.href);
return results[1] || 0;
}
for multi-page template use the following code :
$('#myPage').live('pageshow', function(event, ui) {
var param = $.urlParam('param1');
alert(param);
});
And for a normal template use :
var param = $.urlParam('param1');
alert(param);
And call the page like that :
www.yourwebsite.com/mypage?param1=test&gift=Candy etc...
Upvotes: 4
Reputation: 10993
There is currently no built in way of passing data between JQM pages, you can use the approaches outlined in the answers to the question you linked.
You might also want to look at these SO overflow questions
How-to store variable beetween jQM pages?
How to pass button text to another page?
If your asking how to navigate to the url you posted then you can just use $.mobile.changePage("#MobileHomePage?param1=data¶m2=data1
");
Upvotes: -1