Skip to content

Commit

Permalink
Don't deselect radio buttons in data-toggle; fixes #9920
Browse files Browse the repository at this point in the history
Merges #10787
  • Loading branch information
bleonard authored and cvrebert committed Nov 11, 2013
1 parent 934d1bc commit 5d6e921
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions js/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
}


Expand Down

0 comments on commit 5d6e921

Please sign in to comment.