From 866e99b00cb12dcfa0d9b88edf4f4d0ef06ca3f3 Mon Sep 17 00:00:00 2001 From: Kotas Vlastimil Date: Thu, 14 Jan 2016 17:41:36 +0100 Subject: Button toggling - trigger change event on input MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- js/tests/unit/button.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'js/tests/unit/button.js') 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 = '
' + + '' + + '
' + 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 = '
' -- cgit v1.2.3 From c2616fb74e6bdc0cd46a5678a2c5cffcbe422106 Mon Sep 17 00:00:00 2001 From: Bardi Harborow Date: Tue, 22 Nov 2016 01:36:00 +1100 Subject: Make JS compliant with the new ESLint rules. --- js/tests/unit/button.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'js/tests/unit/button.js') diff --git a/js/tests/unit/button.js b/js/tests/unit/button.js index 5648506cf..7fd86e13a 100644 --- a/js/tests/unit/button.js +++ b/js/tests/unit/button.js @@ -1,5 +1,5 @@ $(function () { - 'use strict'; + 'use strict' QUnit.module('button plugin') -- cgit v1.2.3