git.fiddlerwoaroof.com
Browse code

allow option to close modal on click

fiddlerwoaroof authored on 01/07/2015 02:55:40
Showing 2 changed files
... ...
@@ -14,7 +14,7 @@
14 14
       <button  data-action="open" data-target="#modal2"> open modal! </button>
15 15
       Howdy!
16 16
     </div>
17
-    <div id="modal2">
17
+    <div id="modal2" class="close-on-click">
18 18
       This is the second modal!
19 19
     </div>
20 20
 
... ...
@@ -18,9 +18,12 @@
18 18
           wrapper.removeClass('open');
19 19
           currentModal = null;
20 20
         });
21
-        modal.click(function(ev) {
22
-          ev.stopPropagation();
23
-        });
21
+
22
+        if (! target.hasClass('close-on-click')) {
23
+          modal.click(function(ev) {
24
+            ev.stopPropagation();
25
+          });
26
+        }
24 27
       }
25 28
       $(this).click(function() {
26 29
         if (action === 'open') {