mirror of
https://github.com/twbs/bootstrap.git
synced 2025-02-21 18:54:30 +01:00
parent
934d1bcae5
commit
5d6e9212a6
14
js/button.js
14
js/button.js
@ -54,15 +54,21 @@
|
|||||||
|
|
||||||
Button.prototype.toggle = function () {
|
Button.prototype.toggle = function () {
|
||||||
var $parent = this.$element.closest('[data-toggle="buttons"]')
|
var $parent = this.$element.closest('[data-toggle="buttons"]')
|
||||||
|
var changed = true
|
||||||
|
|
||||||
if ($parent.length) {
|
if ($parent.length) {
|
||||||
var $input = this.$element.find('input')
|
var $input = this.$element.find('input')
|
||||||
.prop('checked', !this.$element.hasClass('active'))
|
if ($input.prop('type') === 'radio') {
|
||||||
.trigger('change')
|
// see if clicking on current one
|
||||||
if ($input.prop('type') === 'radio') $parent.find('.active').removeClass('active')
|
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')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user