]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Handle case when custom checkbox is in other element than label 2065/head
authorArkadiusz Dzięgiel <admin@glorpen.pl>
Thu, 28 Mar 2013 23:33:58 +0000 (00:33 +0100)
committerArkadiusz Dzięgiel <admin@glorpen.pl>
Thu, 28 Mar 2013 23:33:58 +0000 (00:33 +0100)
js/foundation/foundation.forms.js

index 42cafabcb985b648b4713e4b3a6db48aa19b7fe7..2d481c9ff1948cd71c045818d1ddcf843d394abb 100644 (file)
             if ($associatedElement.attr('type') === 'checkbox') {
               e.preventDefault();
               $customCheckbox = $(this).find('span.custom.checkbox');
-              //the checkbox might be outside after the label
+              //the checkbox might be outside after the label or inside of another element
               if ($customCheckbox.length == 0) {
-                $customCheckbox = $(this).siblings('span.custom.checkbox').first();
+                $customCheckbox = $associatedElement.add(this).siblings('span.custom.checkbox').first();
               }
               self.toggle_checkbox($customCheckbox);
             } else if ($associatedElement.attr('type') === 'radio') {
               e.preventDefault();
               $customRadio = $(this).find('span.custom.radio');
-              //the radio might be outside after the label
+              //the radio might be outside after the label or inside of another element
               if ($customRadio.length == 0) {
-                $customRadio = $(this).siblings('span.custom.radio').first();
+                $customRadio = $associatedElement.add(this).siblings('span.custom.radio').first();
               }
               self.toggle_radio($customRadio);
             }