mirror of
https://github.com/twbs/bootstrap.git
synced 2024-11-29 11:24:18 +01:00
Merge pull request #18900 from vlastikcz/v4-dev-buttonChange
Button toggling - trigger change event on input. Fixes #16673, fixes #17599.
This commit is contained in:
commit
b6b8280938
@ -90,7 +90,7 @@ const Button = (($) => {
|
|||||||
|
|
||||||
if (triggerChangeEvent) {
|
if (triggerChangeEvent) {
|
||||||
input.checked = !$(this._element).hasClass(ClassName.ACTIVE)
|
input.checked = !$(this._element).hasClass(ClassName.ACTIVE)
|
||||||
$(this._element).trigger('change')
|
$(input).trigger('change')
|
||||||
}
|
}
|
||||||
|
|
||||||
input.focus()
|
input.focus()
|
||||||
|
@ -72,6 +72,26 @@ $(function () {
|
|||||||
assert.strictEqual($btn.attr('aria-pressed'), 'true', 'btn aria-pressed state is true')
|
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) {
|
QUnit.test('should check for closest matching toggle', function (assert) {
|
||||||
assert.expect(12)
|
assert.expect(12)
|
||||||
var groupHTML = '<div class="btn-group" data-toggle="buttons">'
|
var groupHTML = '<div class="btn-group" data-toggle="buttons">'
|
||||||
|
Loading…
Reference in New Issue
Block a user