Reputation: 2052
When it's a normal jquery mobile page, I can use the following code as onload function:
$(document).delegate("#page", "pageinit", function(){});
However, it's not working when a page is opened as dialog(using ). How can I catch onload event?
Upvotes: 2
Views: 4394
Reputation: 20312
It depends a lot on how your page is structured. First of all your delegate call is targeting a specific id #page
so if your dialog isn't using that id, then it won't be handled. You can use a more generic selector like this:
$(document).delegate('div[data-role=dialog]', 'pageinit', function() {})
I created an example that shows how to capture pageinit and pageshow for normal pages and dialogs http://jsfiddle.net/kiliman/hQh6u/1/
Upvotes: 5