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?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
It depends a lot on how your page is structured. First of all your delegate call is targeting a specific id
#pageso 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/