mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Dialog: Fixed #3087: Added beforeclose callback for dialogs (can prevent closing the dialog by returning false).
This commit is contained in:
parent
7651fb4158
commit
90d7b7f708
@ -622,6 +622,30 @@ test("close", function() {
|
||||
el.remove();
|
||||
});
|
||||
|
||||
test("beforeclose", function() {
|
||||
expect(6);
|
||||
|
||||
el = $('<div/>').dialog({
|
||||
beforeclose: function(ev, ui) {
|
||||
ok(true, '.dialog("close") fires beforeclose callback');
|
||||
equals(this, el[0], "context of callback");
|
||||
return false;
|
||||
}
|
||||
});
|
||||
el.dialog('close');
|
||||
isOpen('beforeclose callback should prevent dialog from closing');
|
||||
el.remove();
|
||||
|
||||
el = $('<div/>').dialog().bind('dialogbeforeclose', function(ev, ui) {
|
||||
ok(true, '.dialog("close") triggers dialogbeforeclose event');
|
||||
equals(this, el[0], "context of event");
|
||||
return false;
|
||||
});
|
||||
el.dialog('close');
|
||||
isOpen('dialogbeforeclose event should prevent dialog from closing');
|
||||
el.remove();
|
||||
});
|
||||
|
||||
module("dialog: Tickets");
|
||||
|
||||
})(jQuery);
|
||||
|
@ -135,6 +135,10 @@ $.widget("ui.dialog", {
|
||||
},
|
||||
|
||||
close: function() {
|
||||
if (false === this._trigger('beforeclose', null, { options: this.options })) {
|
||||
return;
|
||||
}
|
||||
|
||||
(this.overlay && this.overlay.destroy());
|
||||
this.uiDialog
|
||||
.hide(this.options.hide)
|
||||
|
Loading…
Reference in New Issue
Block a user