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");
});

3 thoughts

  1. 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!

  2. 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

Leave a Reply