Skip to content
Permalink
Browse files

Dialog: Fixed #3087: Added beforeclose callback for dialogs (can prev…

…ent closing the dialog by returning false).
  • Loading branch information...
scottgonzalez committed Sep 19, 2008
1 parent 7651fb4 commit 90d7b7f7087a4c18d3648775ba062e95aab9ff77
Showing with 28 additions and 0 deletions.
  1. +24 −0 tests/dialog.js
  2. +4 −0 ui/ui.dialog.js
@@ -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)

0 comments on commit 90d7b7f

Please sign in to comment.
You can’t perform that action at this time.