]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
Custom forms checkbox and radio fix 1977/head
authorAndreas Goetz <cpuidle@gmx.de>
Wed, 20 Mar 2013 18:39:05 +0000 (19:39 +0100)
committerAndreas Goetz <cpuidle@gmx.de>
Wed, 20 Mar 2013 18:39:05 +0000 (19:39 +0100)
js/foundation/foundation.forms.js

index 43bf4515d2b996cd6669a23122816ea6131a2e6d..089406b0116336dd6233dca31c5cdb735de6396a 100644 (file)
             if ($associatedElement.attr('type') === 'checkbox') {
               e.preventDefault();
               $customCheckbox = $(this).find('span.custom.checkbox');
-
               //the checkbox might be outside after the label
               if ($customCheckbox.length == 0) {
-                $customCheckbox = $(this).next('span.custom.checkbox');
-              }
-              //the checkbox might be outside before the label
-              if ($customCheckbox.length == 0) {
-                $customCheckbox = $(this).prev('span.custom.checkbox');
+                $customCheckbox = $(this).siblings('span.custom.checkbox').first();
               }
               self.toggle_checkbox($customCheckbox);
             } else if ($associatedElement.attr('type') === 'radio') {
               $customRadio = $(this).find('span.custom.radio');
               //the radio might be outside after the label
               if ($customRadio.length == 0) {
-                $customRadio = $(this).next('span.custom.radio');
-              }
-              //the radio might be outside before the label
-              if ($customRadio.length == 0) {
-                $customRadio = $(this).prev('span.custom.radio');
+                $customRadio = $(this).siblings('span.custom.radio').first();
               }
               self.toggle_radio($customRadio);
             }