Trigger event on dialog box open

user2583714 picture user2583714 · Sep 24, 2013 · Viewed 61.7k times · Source

My dialog box is defined under the div

#dialogbox

When the dialog box opens i want to trigger an event such that it alerts open. The code im using is:

$("#dialogbox").dialog({open: function(){
           alert("OPEN");
          }
});

But this doesnt seem to trigger when dialog box is opened Please help

Answer

Donovan Charpin picture Donovan Charpin · Sep 24, 2013

You can use this :

$( ".selector" ).dialog({
  open: function( event, ui ) {}
});

or the event listener .on

$( ".selector" ).on( "dialogopen", function( event, ui ) {} );

More information in this page :

http://api.jqueryui.com/dialog/#event-open