1
0
mirror of https://github.com/twbs/bootstrap.git synced 2025-08-06 13:46:42 +02:00

get button js working with actual form elements p cooll

This commit is contained in:
fat
2013-07-18 00:59:31 -07:00
parent 2a4a0f70ef
commit 37e899d766
7 changed files with 52 additions and 34 deletions

View File

@@ -53,10 +53,11 @@
}
Button.prototype.toggle = function () {
var $parent = this.$element.closest('[data-toggle="buttons-radio"]')
var $parent = this.$element.closest('[data-toggle="buttons"]')
if ($parent) {
$parent.find('.active').removeClass('active')
if ($parent.length) {
var $input = this.$element.find('input').prop('checked', !this.$element.hasClass('active'))
if ($input.prop('type') === 'radio') $parent.find('.active').removeClass('active')
}
this.$element.toggleClass('active')
@@ -98,6 +99,7 @@
$(document).on('click.bs.button.data-api', '[data-toggle^=button]', function (e) {
var $btn = $(e.target)
if ($btn.has('input').length) return // throw away double event for inputs
if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn')
$btn.button('toggle')
})