aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Leonard <[email protected]>2013-09-01 22:23:31 -0700
committerChris Rebert <[email protected]>2013-11-10 17:23:11 -0800
commit5d6e9212a642430719702ead322103e19c6aa782 (patch)
tree521e88b4692dff5bf6efc895ead7a94b032b9bd7
parent934d1bcae588a278900018abb648242eb05328b3 (diff)
downloadbootstrap-5d6e9212a642430719702ead322103e19c6aa782.tar.xz
bootstrap-5d6e9212a642430719702ead322103e19c6aa782.zip
Don't deselect radio buttons in data-toggle; fixes #9920
Merges #10787
-rw-r--r--js/button.js14
1 files changed, 10 insertions, 4 deletions
diff --git a/js/button.js b/js/button.js
index 0145689dd..3c1613506 100644
--- a/js/button.js
+++ b/js/button.js
@@ -54,15 +54,21 @@
Button.prototype.toggle = function () {
var $parent = this.$element.closest('[data-toggle="buttons"]')
+ var changed = true
if ($parent.length) {
var $input = this.$element.find('input')
- .prop('checked', !this.$element.hasClass('active'))
- .trigger('change')
- if ($input.prop('type') === 'radio') $parent.find('.active').removeClass('active')
+ if ($input.prop('type') === 'radio') {
+ // see if clicking on current one
+ if ($input.prop('checked') && this.$element.hasClass('active'))
+ changed = false
+ else
+ $parent.find('.active').removeClass('active')
+ }
+ if (changed) $input.prop('checked', !this.$element.hasClass('active')).trigger('change')
}
- this.$element.toggleClass('active')
+ if (changed) this.$element.toggleClass('active')
}