Skip to content

Commit

Permalink
Dialog: Use _hide() to make sure close event gets triggered. Fixes #8…
Browse files Browse the repository at this point in the history
…684 - jQuery dialog with hide options does not trigger close event.
  • Loading branch information
petersendidit authored and scottgonzalez committed Oct 18, 2012
1 parent dda1925 commit 35dc930
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
21 changes: 19 additions & 2 deletions tests/unit/dialog/dialog_events.js
Expand Up @@ -195,8 +195,8 @@ test("resizeStop", function() {
el.remove();
});

test("close", function() {
expect(7);
asyncTest("close", function() {
expect(14);

el = $('<div></div>').dialog({
close: function(ev, ui) {
Expand All @@ -212,6 +212,23 @@ test("close", function() {
});
el.dialog('close');
el.remove();

// Close event with an effect
el = $('<div></div>').dialog({
hide: 10,
close: function(ev, ui) {
ok(true, '.dialog("close") fires close callback');
equal(this, el[0], "context of callback");
equal(ev.type, 'dialogclose', 'event type in callback');
deepEqual(ui, {}, 'ui hash in callback');
start();
}
}).bind('dialogclose', function(ev, ui) {
ok(true, '.dialog("close") fires dialogclose event');
equal(this, el[0], 'context of event');
deepEqual(ui, {}, 'ui hash in event');
});
el.dialog('close');
});

test("beforeClose", function() {
Expand Down
2 changes: 1 addition & 1 deletion ui/jquery.ui.dialog.js
Expand Up @@ -251,7 +251,7 @@ $.widget("ui.dialog", {
}

if ( this.options.hide ) {
this.uiDialog.hide( this.options.hide, function() {
this._hide( this.uiDialog, this.options.hide, function() {
that._trigger( "close", event );
});
} else {
Expand Down

0 comments on commit 35dc930

Please sign in to comment.