From b06b8779cc7d309a38399bc76b71902397af61bc Mon Sep 17 00:00:00 2001 From: Michael de Hoog Date: Mon, 12 Oct 2015 19:49:43 +1000 Subject: [PATCH] Added the ability to cancel a modal hide from the onHide callback --- src/definitions/modules/modal.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/definitions/modules/modal.js b/src/definitions/modules/modal.js index 4d24a41ce..d35be7e6b 100644 --- a/src/definitions/modules/modal.js +++ b/src/definitions/modules/modal.js @@ -365,7 +365,10 @@ $.fn.modal = function(parameters) { : function(){} ; module.debug('Hiding modal'); - settings.onHide.call(element); + if(settings.onHide.call(element, $(this)) === false) { + module.verbose('Hide callback returned false cancelling hide'); + return; + } if( module.is.animating() || module.is.active() ) { if(settings.transition && $.fn.transition !== undefined && $module.transition('is supported')) { @@ -854,7 +857,7 @@ $.fn.modal.settings = { onVisible : function(){}, // called before hide animation - onHide : function(){}, + onHide : function(){ return true; }, // called after hide animation onHidden : function(){},