How to get child pageload event?
I'm using JQuery-Mobile.
On specific child page loads开发者_StackOverflow社区, I want to perform one JavaScript function.
So How do I get the child page load event?
Child page will be loaded with Ajax form submission. Somewhat like: I have master page, in that I load page1 and submit it to page2. So response would be a page2 and with master page as hidden.
This is the fix for speed/quality: (less functin calls, no implicit checking of attributes)
$('#page2').live('pageshow',function(event, ui){
//you code
});
<div data-role="page" id="page2">
//code
</div>
This is how it should be done since jQuery Mobile alpha3:
$('div[data-url="some.html"]').live('pageshow',function(event, ui){
//you code
});
and no hacks in HTML
You can put following JavaScript on parent page:
$('div').live('pageshow',function(event, ui){
if($(this).attr("id") == "page2")
{
//you code
}
});
On the child page:
<div data-role="page" id="page2">
//code
</div>
This is what worked for me. Am using jquery.mobile-1.0b1.min.js
$('#MapView').bind('pageshow', function() {
console.log('show MapView');
//Add Your Code here
Reloadmap();
});
The Page elements include
<div data-role="page" id="MapView">
//code
</div>
精彩评论