From d65523c015158728e1879a5364368ef110f156ac Mon Sep 17 00:00:00 2001 From: Alastair Brayne Date: Thu, 16 Jan 2014 22:02:48 +0000 Subject: [PATCH] If an event handler is set via delegation on a parent container, as the modal is technically still a child of that container, the close action can lead to an undesirable bubbling. This commit fixes that by adding preventDefault and return false protection to all click events. --- jquery.leanModal.js | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/jquery.leanModal.js b/jquery.leanModal.js index facf07e..cef223e 100644 --- a/jquery.leanModal.js +++ b/jquery.leanModal.js @@ -24,12 +24,16 @@ var modal_id = $(this).attr("href"); - $("#lean_overlay").click(function() { - close_modal(modal_id); + $("#lean_overlay").click(function(e) { + close_modal(modal_id); + e.preventDefault(); + return false; }); - - $(o.closeButton).click(function() { - close_modal(modal_id); + + $(o.closeButton).click(function(e) { + close_modal(modal_id); + e.preventDefault(); + return false; }); var modal_height = $(modal_id).outerHeight(); @@ -54,7 +58,7 @@ $(modal_id).fadeTo(200,1); e.preventDefault(); - + return false; }); });