diff options
| author | Chris Rebert <[email protected]> | 2013-11-10 17:33:12 -0800 |
|---|---|---|
| committer | Chris Rebert <[email protected]> | 2013-11-10 17:33:12 -0800 |
| commit | e7d6af003e6af02c26cc8864da72dc807f8f97a1 (patch) | |
| tree | 61bc32a87d9439acdcf2b6bc2dd049b566f645ce /js/button.js | |
| parent | a639c6e1cf2eb0457be84290f7848c3eb9eaad27 (diff) | |
| parent | 7a3f41b11b15f4b931aa43cf1a2fd7a00db6f817 (diff) | |
| download | bootstrap-e7d6af003e6af02c26cc8864da72dc807f8f97a1.tar.xz bootstrap-e7d6af003e6af02c26cc8864da72dc807f8f97a1.zip | |
Merge pull request #11376 from twbs/double-click-radio-fix
Double-clicking on a .btn-ized radio button shouldn't de-select it
Diffstat (limited to 'js/button.js')
| -rw-r--r-- | js/button.js | 14 |
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') } |
