diff --git a/README.md b/README.md index bd01c17..855eee0 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/jquery.modal.js b/jquery.modal.js index 1c20e5a..9fa020b 100644 --- a/jquery.modal.js +++ b/jquery.modal.js @@ -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()]); }, @@ -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';