From 7d64b86c6cd66bb5e9a297f270d674b69624cbd7 Mon Sep 17 00:00:00 2001 From: jlukic Date: Mon, 6 Jul 2015 14:19:11 -0400 Subject: [PATCH] Checkbox- Fixes issue where radio checkbox would uncheck itself mistakenly when unchecking other radios #2506 --- RELEASE-NOTES.md | 2 + src/definitions/modules/checkbox.js | 63 ++++++++++++++++------------- 2 files changed, 38 insertions(+), 27 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 1f385a82ef..4e82beac9c 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -20,10 +20,12 @@ - **Modal** - `scrolling modal` now correctly inherits rules so that it appears at top of screen on mobile - **Menu** - Inverted menu no longer includes a 1px transparent border. - **Menu** - Fixes `compact vertical menu` using `flex` style incorrectly +- **Tab** - Fixed bug where remote loaded tab content would not show `loading tab` on first load. **Docs** - **Image** - Added docs for missing `fluid image` variation - **Modal** - Removed legacy JS animation settings still accidentally in docs +- **Tab** - Added new examples for `evaluateScripts` and HTML5 state tabs ### Version 2.0.0 - June 30, 2015 diff --git a/src/definitions/modules/checkbox.js b/src/definitions/modules/checkbox.js index 49e1786b79..029344bf02 100644 --- a/src/definitions/modules/checkbox.js +++ b/src/definitions/modules/checkbox.js @@ -271,6 +271,9 @@ $.fn.checkbox = function(parameters) { ; return $('input[name="' + name + '"]').closest(selector.checkbox); }, + otherRadios: function() { + return module.get.radios().not($module); + }, name: function() { return $input.attr('name'); } @@ -314,25 +317,31 @@ $.fn.checkbox = function(parameters) { set: { checked: function() { + module.verbose('Setting class to checked'); + $module + .removeClass(className.indeterminate) + .addClass(className.checked) + ; + if( module.is.radio() ) { + module.uncheckOthers(); + } if(!module.is.indeterminate() && module.is.checked()) { - module.debug('Input is already checked'); + module.debug('Input is already checked, skipping input property change'); return; } module.verbose('Setting state to checked', $input[0]); - if( module.is.radio() ) { - module.uncheckOthers(); - } $input .prop('indeterminate', false) .prop('checked', true) ; - $module - .removeClass(className.indeterminate) - .addClass(className.checked) - ; module.trigger.change(); }, unchecked: function() { + module.verbose('Removing checked class'); + $module + .removeClass(className.indeterminate) + .removeClass(className.checked) + ; if(!module.is.indeterminate() && module.is.unchecked() ) { module.debug('Input is already unchecked'); return; @@ -342,63 +351,63 @@ $.fn.checkbox = function(parameters) { .prop('indeterminate', false) .prop('checked', false) ; - $module - .removeClass(className.indeterminate) - .removeClass(className.checked) - ; module.trigger.change(); }, indeterminate: function() { + module.verbose('Setting class to indeterminate'); + $module + .addClass(className.indeterminate) + ; if( module.is.indeterminate() ) { - module.debug('Input is already indeterminate'); + module.debug('Input is already indeterminate, skipping input property change'); return; } module.debug('Setting state to indeterminate'); $input .prop('indeterminate', true) ; - $module - .addClass(className.indeterminate) - ; module.trigger.change(); }, determinate: function() { + module.verbose('Removing indeterminate class'); + $module + .removeClass(className.indeterminate) + ; if( module.is.determinate() ) { - module.debug('Input is already determinate'); + module.debug('Input is already determinate, skipping input property change'); return; } module.debug('Setting state to determinate'); $input .prop('indeterminate', false) ; - $module - .removeClass(className.indeterminate) - ; }, disabled: function() { + module.verbose('Setting class to disabled'); + $module + .addClass(className.disabled) + ; if( module.is.disabled() ) { - module.debug('Input is already disabled'); + module.debug('Input is already disabled, skipping input property change'); return; } module.debug('Setting state to disabled'); $input .prop('disabled', 'disabled') ; - $module - .addClass(className.disabled) - ; module.trigger.change(); }, enabled: function() { + module.verbose('Removing disabled class'); + $module.removeClass(className.disabled); if( module.is.enabled() ) { - module.debug('Input is already enabled'); + module.debug('Input is already enabled, skipping input property change'); return; } module.debug('Setting state to enabled'); $input .prop('disabled', false) ; - $module.removeClass(className.disabled); module.trigger.change(); }, tabbable: function() { @@ -459,7 +468,7 @@ $.fn.checkbox = function(parameters) { uncheckOthers: function() { var - $radios = module.get.radios() + $radios = module.get.otherRadios() ; module.debug('Unchecking other radios', $radios); $radios.removeClass(className.checked);