Skip to content

Commit

Permalink
Add AFTER_CLOSE event (fixes #122)
Browse files Browse the repository at this point in the history
  • Loading branch information
paaatrick committed Oct 7, 2015
1 parent f28d2cd commit fc55c9e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ The following events are triggered on the modal element at various points in the
$.modal.OPEN = 'modal:open';
$.modal.BEFORE_CLOSE = 'modal:before-close';
$.modal.CLOSE = 'modal:close';
$.modal.AFTER_CLOSE = 'modal:after-close';

The first and only argument passed to these event handlers is the `modal` object, which has three properties:

Expand Down
10 changes: 8 additions & 2 deletions jquery.modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,15 @@
if (this.closeButton) this.closeButton.remove();
this.$elm.removeClass('current');

var _this = this;
if(this.options.doFade) {
this.$elm.fadeOut(this.options.fadeDuration);
this.$elm.fadeOut(this.options.fadeDuration, function () {
_this.$elm.trigger($.modal.AFTER_CLOSE, [_this._ctx()]);
});
} else {
this.$elm.hide();
this.$elm.hide(function () {
_this.$elm.trigger($.modal.AFTER_CLOSE, [_this._ctx()]);
});
}
this.$elm.trigger($.modal.CLOSE, [this._ctx()]);
},
Expand Down Expand Up @@ -205,6 +210,7 @@
$.modal.OPEN = 'modal:open';
$.modal.BEFORE_CLOSE = 'modal:before-close';
$.modal.CLOSE = 'modal:close';
$.modal.AFTER_CLOSE = 'modal:after-close';
$.modal.AJAX_SEND = 'modal:ajax:send';
$.modal.AJAX_SUCCESS = 'modal:ajax:success';
$.modal.AJAX_FAIL = 'modal:ajax:fail';
Expand Down

0 comments on commit fc55c9e

Please sign in to comment.