I needed to trap the events triggered when a dialog is opened and closed in a jQuery Mobile app. After trying all sorts of combinations of open, close, and dialog events, I found that these will do the trick:
// Dialog opened
$('#myDialog').on("pageshow", function() {
alert("Opened");
});
// Dialog closed
$('#myDialog').on("pagehide", function() {
alert("Closed");
});
Trapping jQuery Mobile Dialog Open And Close
·
3 Comments
B
In jQuery 1.6.4 use .live(), it'll work as well.
C
Chris Stahl
The only problem with this solution is that it requires the jQuery on() method which requires jQuery 1.7 and JQM uses 1.6.4. Hopefully they'll get JQM fully supporting 1.7 soon as this would solve a lot of my problems!
T
Tanveer
Hi, thanks for this code, actually i was implementing jquery autocomplete in dialog, but it was not working at all. then i use this script to register my code snippet. and it works
Thanks