Trapping jQuery Mobile Dialog Open And Close

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() {
// Dialog closed
$('#myDialog').on("pagehide", function() {

3 responses to “Trapping jQuery Mobile Dialog Open And Close”

  1. Chris Stahl Avatar
    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!

  2. Ben Forta Avatar
    Ben Forta

    In jQuery 1.6.4 use .live(), it’ll work as well.

  3. Tanveer Avatar

    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

Leave a Reply