diff options
| author | Kotas Vlastimil <[email protected]> | 2016-01-14 17:41:36 +0100 |
|---|---|---|
| committer | Kotas Vlastimil <[email protected]> | 2016-01-14 20:26:32 +0100 |
| commit | 866e99b00cb12dcfa0d9b88edf4f4d0ef06ca3f3 (patch) | |
| tree | e969c95e8d2595ee40a566d345f6e855442ede16 /js/tests/unit | |
| parent | 5e893434c794b328f3c49638bfbb527f356aa6de (diff) | |
| download | bootstrap-866e99b00cb12dcfa0d9b88edf4f4d0ef06ca3f3.tar.xz bootstrap-866e99b00cb12dcfa0d9b88edf4f4d0ef06ca3f3.zip | |
Button toggling - trigger change event on input
Bootstrap’s .button styles can be applied to other elements, such as labels, to provide checkbox or radio style button toggling.
When the checkbox or radio state is changed, there should be triggered the change event. Currently, the change event is triggered on the Button, which is not correct. Only input fields do support the change event.
Diffstat (limited to 'js/tests/unit')
| -rw-r--r-- | js/tests/unit/button.js | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/js/tests/unit/button.js b/js/tests/unit/button.js index 5648506cf..f0ce96488 100644 --- a/js/tests/unit/button.js +++ b/js/tests/unit/button.js @@ -72,6 +72,26 @@ $(function () { assert.strictEqual($btn.attr('aria-pressed'), 'true', 'btn aria-pressed state is true') }) + QUnit.test('should trigger input change event when toggled button has input field', function (assert) { + assert.expect(1) + var done = assert.async() + + var groupHTML = '<div class="btn-group" data-toggle="buttons">' + + '<label class="btn btn-primary">' + + '<input type="radio" id="radio" autocomplete="off">Radio' + + '</label>' + + '</div>' + var $group = $(groupHTML).appendTo('#qunit-fixture') + + $group.find('input').on('change', function (e) { + e.preventDefault() + assert.ok(true, 'change event fired') + done() + }) + + $group.find('label').trigger('click') + }) + QUnit.test('should check for closest matching toggle', function (assert) { assert.expect(12) var groupHTML = '<div class="btn-group" data-toggle="buttons">' |
