Question

I have a jQuery dialog that loads its content via Ajax.

The view that has been loaded into the dialog then needs to attach methods to the jQuery dialog object's events.

Im not sure how to go about this though. I tried using $("#myelement").closest("div.ui-dialog") (which does work) but it doesn't permit me to hook into its close or resize events.

Is there a way (given the ID of the div that the dialog was originally created from) to access the original jQuery dialog object?

Était-ce utile?

La solution

If i understand your issue:

$("#myelement").closest("div.ui-dialog").dialog("option","close",function(){
    alert("parent dialog closed!");
});

Autres conseils

Check the documentation : the "close event" real name is dialogclose.
There is no event triggered on destroy.
There is, if you need it, a dialogbeforeclose event.

You don't need to go up to the .ui-dialog to listen for this event :

$('#myelement').on('dialogclose', function(){ ... });

If you want to call a dialog method, the syntax is :

$('#myelement').dialog('close');
$('#myelement').dialog('destroy');
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top