diff --git a/docs/assets/bootstrap.zip b/docs/assets/bootstrap.zip index 4cad194d74..9add96d32b 100644 Binary files a/docs/assets/bootstrap.zip and b/docs/assets/bootstrap.zip differ diff --git a/docs/assets/js/bootstrap-button.js b/docs/assets/js/bootstrap-button.js index a0e0535475..0238ca3cb9 100644 --- a/docs/assets/js/bootstrap-button.js +++ b/docs/assets/js/bootstrap-button.js @@ -91,7 +91,9 @@ $(function () { $('body').on('click.button.data-api', '[data-toggle^=button]', function ( e ) { - $(e.currentTarget).button('toggle') + var $btn = $(e.target) + if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') + $btn.button('toggle') }) }) diff --git a/js/bootstrap-button.js b/js/bootstrap-button.js index a0e0535475..0238ca3cb9 100644 --- a/js/bootstrap-button.js +++ b/js/bootstrap-button.js @@ -91,7 +91,9 @@ $(function () { $('body').on('click.button.data-api', '[data-toggle^=button]', function ( e ) { - $(e.currentTarget).button('toggle') + var $btn = $(e.target) + if (!$btn.hasClass('btn')) $btn = $btn.closest('.btn') + $btn.button('toggle') }) }) diff --git a/js/tests/unit/bootstrap-button.js b/js/tests/unit/bootstrap-button.js index 8aed857e11..03c4a8e9d5 100644 --- a/js/tests/unit/bootstrap-button.js +++ b/js/tests/unit/bootstrap-button.js @@ -45,10 +45,33 @@ $(function () { }) test("should toggle active", function () { - var btn = $('') + var btn = $('') ok(!btn.hasClass('active'), 'btn does not have active class') btn.button('toggle') ok(btn.hasClass('active'), 'btn has class active') }) + test("should toggle active when btn children are clicked", function () { + var btn = $('') + , inner = $('') + btn + .append(inner) + .appendTo($('#qunit-fixture')) + ok(!btn.hasClass('active'), 'btn does not have active class') + inner.click() + ok(btn.hasClass('active'), 'btn has class active') + }) + + test("should toggle active when btn children are clicked within btn-group", function () { + var btngroup = $('
') + , btn = $('') + , inner = $('') + btngroup + .append(btn.append(inner)) + .appendTo($('#qunit-fixture')) + ok(!btn.hasClass('active'), 'btn does not have active class') + inner.click() + ok(btn.hasClass('active'), 'btn has class active') + }) + }) \ No newline at end of file