javascript - jQuery Mobile $.mobile.changePage post to page -
javascript - jQuery Mobile $.mobile.changePage post to page -
i'm using jquery mobile create mobile (obviously) website. have list of items created dynamically based off ajax request. works well!
the next thing these list items need link "page" require parameter beingness sent it.
the code i'm using is:
$("#cwcountries [data-role='listview'] a").live("click", function() { var dataurl = $(this).data("url"); if(dataurl != null) { $.mobile.changepage($("#cwcountryspec"), { type: "post", data: dataurl }); } });
which alter cwcountryspec
page you'd expect. can see i'm using sec parameter in $.mobile.changepage
pass info through want already-existent page able receive , create utilize of.
i can intercept alter cwcountryspec
code:
$("#cwcountryspec").live('pagebeforecreate', function(event) { console.log(event); });
but when check console, data
value returned undefined
.
is possible, , if so, how?
edit that's shame...
i've check jquery mobile methods docs, , states,
used when 'to' argument of changepage() url.
that sucks. how else can send info between page change?
how setting 'dataurl' value global variable, , picking-up value of global variable when '#cwcountryspec' page loads.
var tmp_data; $("#cwcountries [data-role='listview'] a").live("click", function() { var dataurl = $(this).data("url"); if(dataurl != null) { tmp_data = dataurl; $.mobile.changepage($("#cwcountryspec")); } }); $("#cwcountryspec").live('pagebeforeshow', function() { console.log(tmp_data); });---- edit ----
when load info new page, can check see if page empty or not page loaded once.
$("#cwcountryspec").live('pagebeforeshow', function() { if ($("#cwcountryspec div[data-role='content']").is(':empty')) { $("#cwcountryspec div[data-role='content']").load(tmp_data); } console.log(tmp_data); }); javascript jquery mobile
Comments
Post a Comment