diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 63701c236..f7083591a 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -10,6 +10,7 @@ - **Button** - Fixes `@basicActiveBoxShadow` being used incorrectly in basic button variables - **Visibility** - Fixes issue where visibility events would occur improperly when using a `context` that have `overflow-x` or `overflow-y` set to `auto` - **Dropdown** - Fixes an issue where dropdown would not correctly open `upward` at bottom edge of the screen when using a `context` with `overflow-x` or `overflow-y` set to `auto` +- **Modal** - `onDeny` and `onApprove` callbacks can no longer occur multiple times if you rapidly click a approve/deny button in a modal. #4479 ### Version 2.2.10 - February 21, 2017 diff --git a/src/definitions/modules/modal.js b/src/definitions/modules/modal.js index b8c32f5a6..9de8673de 100644 --- a/src/definitions/modules/modal.js +++ b/src/definitions/modules/modal.js @@ -72,6 +72,8 @@ $.fn.modal = function(parameters) { element = this, instance = $module.data(moduleNamespace), + ignoreRepeatedEvents = false, + elementEventNamespace, id, observer, @@ -226,18 +228,24 @@ $.fn.modal = function(parameters) { event: { approve: function() { - if(settings.onApprove.call(element, $(this)) === false) { + if(ignoreRepeatedEvents || settings.onApprove.call(element, $(this)) === false) { module.verbose('Approve callback returned false cancelling hide'); return; } - module.hide(); + ignoreRepeatedEvents = true; + module.hide(function() { + ignoreRepeatedEvents = false; + }); }, deny: function() { - if(settings.onDeny.call(element, $(this)) === false) { + if(ignoreRepeatedEvents || settings.onDeny.call(element, $(this)) === false) { module.verbose('Deny callback returned false cancelling hide'); return; } - module.hide(); + ignoreRepeatedEvents = true; + module.hide(function() { + ignoreRepeatedEvents = false; + }); }, close: function() { module.hide();