jQM - Javascript doesn't work in 'file.html' when use $.mobile.changePage -
i'm trying make transition between 2 .html files using jqm (just test):
index.html:
<script> function go(){ var url = "go.html?go='123'"; $.mobile.changepage(url, {transition: "slide"}); } </script> <body> <button onclick='go();'>go!</button> </body>
go.html:
<script> $( document ).on("#mainpage", "pageinit", function() { // code url vars function geturlvars() { var vars = {}; var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m,key,value) { vars[key] = value; }); return vars; } var go = geturlvars()['go']; alert(go); }); </script>
the transition works fine, , see (in url browser) variable 'go' there (123).
when translation finish, alert doesn't work , have refresh page (f5) see alert ('123'): javascript in go.html doesn't work.
how can fix issue?
the scripts want executed on page need handled on pageinit
or pagechange
event in jqm. go read scripting section on jqm docs.
Comments
Post a Comment