mirror of
https://github.com/Hopiu/bootstrap.git
synced 2026-03-20 22:40:23 +00:00
fix for #4761
This commit is contained in:
parent
d797a5fbd7
commit
601e252074
5 changed files with 24 additions and 5 deletions
2
docs/assets/js/bootstrap-button.js
vendored
2
docs/assets/js/bootstrap-button.js
vendored
|
|
@ -51,7 +51,7 @@
|
|||
}
|
||||
|
||||
Button.prototype.toggle = function () {
|
||||
var $parent = this.$element.parent('[data-toggle="buttons-radio"]')
|
||||
var $parent = this.$element.closest('[data-toggle="buttons-radio"]')
|
||||
|
||||
$parent && $parent
|
||||
.find('.active')
|
||||
|
|
|
|||
2
docs/assets/js/bootstrap.js
vendored
2
docs/assets/js/bootstrap.js
vendored
|
|
@ -199,7 +199,7 @@
|
|||
}
|
||||
|
||||
Button.prototype.toggle = function () {
|
||||
var $parent = this.$element.parent('[data-toggle="buttons-radio"]')
|
||||
var $parent = this.$element.closest('[data-toggle="buttons-radio"]')
|
||||
|
||||
$parent && $parent
|
||||
.find('.active')
|
||||
|
|
|
|||
2
docs/assets/js/bootstrap.min.js
vendored
2
docs/assets/js/bootstrap.min.js
vendored
File diff suppressed because one or more lines are too long
2
js/bootstrap-button.js
vendored
2
js/bootstrap-button.js
vendored
|
|
@ -51,7 +51,7 @@
|
|||
}
|
||||
|
||||
Button.prototype.toggle = function () {
|
||||
var $parent = this.$element.parent('[data-toggle="buttons-radio"]')
|
||||
var $parent = this.$element.closest('[data-toggle="buttons-radio"]')
|
||||
|
||||
$parent && $parent
|
||||
.find('.active')
|
||||
|
|
|
|||
21
js/tests/unit/bootstrap-button.js
vendored
21
js/tests/unit/bootstrap-button.js
vendored
|
|
@ -62,7 +62,7 @@ $(function () {
|
|||
ok(btn.hasClass('active'), 'btn has class active')
|
||||
})
|
||||
|
||||
test("should toggle active when btn children are clicked within btn-group", function () {
|
||||
test("should toggle active when btn children are clicked within btn-group", function () {
|
||||
var btngroup = $('<div class="btn-group" data-toggle="buttons-checkbox"></div>')
|
||||
, btn = $('<button class="btn">fat</button>')
|
||||
, inner = $('<i></i>')
|
||||
|
|
@ -74,4 +74,23 @@ $(function () {
|
|||
ok(btn.hasClass('active'), 'btn has class active')
|
||||
})
|
||||
|
||||
test("should check for closest matching toggle", function () {
|
||||
var group = $("<div data-toggle='buttons-radio'></div>")
|
||||
, btn1 = $("<button class='btn active'></button>")
|
||||
, btn2 = $("<button class='btn'></button>")
|
||||
, wrap = $("<div></div>")
|
||||
|
||||
wrap.append(btn1, btn2)
|
||||
|
||||
group
|
||||
.append(wrap)
|
||||
.appendTo($('#qunit-fixture'))
|
||||
|
||||
ok(btn1.hasClass('active'), 'btn1 has active class')
|
||||
ok(!btn2.hasClass('active'), 'btn2 does not have active class')
|
||||
btn2.click()
|
||||
ok(!btn1.hasClass('active'), 'btn1 does not have active class')
|
||||
ok(btn2.hasClass('active'), 'btn2 has active class')
|
||||
})
|
||||
|
||||
})
|
||||
Loading…
Reference in a new issue