but onload function is not firing up....if I try to refresh the page (occassion.html) then onload function gets fired up... why it is not working when navigated from index.html?
If I remove the jQuery files, then it works as expected....what I am missing to add?
This is also not working
$(document).ready(function () {
loaded();
});
Edit
I added
<script>
$(document).bind("pagechange", function (event, data) {
console.log(data);
var toPage = data.toPage[0].id;
alert(toPage);
if (toPage == "page2")
alert("hello");
});
</script>
and put the following in occassion.html
<div data-role="page" id="page2">
hello
</div>
To my surprise not even the alert(hello) is firing but also hello is also not displayed and alert(topage) is coming empty..
How is it? what's missing
解决方案
jQuery Mobile uses AJAX to pull pages into the DOM, that's how it can transition between pages. When jQuery Mobile does this, there is a good chance it's doing it after the window.load event fires, so that event will generally not fire unless you refresh the page (then window.load will fire again). It seems possible that a user could click a link and have it load before the window.load event fires, but I wouldn't expect that to be the norm.