diff options
| author | fat <[email protected]> | 2013-07-18 00:59:31 -0700 |
|---|---|---|
| committer | fat <[email protected]> | 2013-07-18 00:59:31 -0700 |
| commit | 37e899d76630d29565c0c6ff67885eee01777e1a (patch) | |
| tree | 12f6e9985723e6b167d5ed01b8693ffd3b5079f9 /js/button.js | |
| parent | 2a4a0f70ef6dde303d92ee2bcc082d9e9aad181b (diff) | |
| download | bootstrap-37e899d76630d29565c0c6ff67885eee01777e1a.tar.xz bootstrap-37e899d76630d29565c0c6ff67885eee01777e1a.zip | |
get button js working with actual form elements p cooll
Diffstat (limited to 'js/button.js')
| -rw-r--r-- | js/button.js | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/js/button.js b/js/button.js index c29647840..c0127cc5f 100644 --- a/js/button.js +++ b/js/button.js @@ -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') }) |
