Skip to content

Commit e851b86

Browse files
committed
Merge pull request twbs#14457 from hnrch02/button-set-val-after-event-loop
Change value of stateful button after event loop
2 parents 2aac61e + c207b5b commit e851b86

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

js/button.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535

3636
if (data.resetText == null) $el.data('resetText', $el[val]())
3737

38-
$el[val](data[state] == null ? this.options[state] : data[state])
39-
4038
// push to event loop to allow forms to submit
4139
setTimeout($.proxy(function () {
40+
$el[val](data[state] == null ? this.options[state] : data[state])
41+
4242
if (state == 'loadingText') {
4343
this.isLoading = true
4444
$el.addClass(d).attr(d, d)

js/tests/unit/button.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,9 @@ $(function () {
3333
var $btn = $('<button class="btn" data-loading-text="fat">mdo</button>')
3434
equal($btn.html(), 'mdo', 'btn text equals mdo')
3535
$btn.bootstrapButton('loading')
36-
equal($btn.html(), 'fat', 'btn text equals fat')
3736
stop()
3837
setTimeout(function () {
38+
equal($btn.html(), 'fat', 'btn text equals fat')
3939
ok($btn[0].hasAttribute('disabled'), 'btn is disabled')
4040
ok($btn.hasClass('disabled'), 'btn has disabled class')
4141
start()
@@ -46,16 +46,16 @@ $(function () {
4646
var $btn = $('<button class="btn" data-loading-text="fat">mdo</button>')
4747
equal($btn.html(), 'mdo', 'btn text equals mdo')
4848
$btn.bootstrapButton('loading')
49-
equal($btn.html(), 'fat', 'btn text equals fat')
5049
stop()
5150
setTimeout(function () {
51+
equal($btn.html(), 'fat', 'btn text equals fat')
5252
ok($btn[0].hasAttribute('disabled'), 'btn is disabled')
5353
ok($btn.hasClass('disabled'), 'btn has disabled class')
5454
start()
5555
stop()
5656
$btn.bootstrapButton('reset')
57-
equal($btn.html(), 'mdo', 'btn text equals mdo')
5857
setTimeout(function () {
58+
equal($btn.html(), 'mdo', 'btn text equals mdo')
5959
ok(!$btn[0].hasAttribute('disabled'), 'btn is not disabled')
6060
ok(!$btn.hasClass('disabled'), 'btn does not have disabled class')
6161
start()
@@ -67,16 +67,16 @@ $(function () {
6767
var $btn = $('<button class="btn" data-loading-text="fat"/>')
6868
equal($btn.html(), '', 'btn text equals ""')
6969
$btn.bootstrapButton('loading')
70-
equal($btn.html(), 'fat', 'btn text equals fat')
7170
stop()
7271
setTimeout(function () {
72+
equal($btn.html(), 'fat', 'btn text equals fat')
7373
ok($btn[0].hasAttribute('disabled'), 'btn is disabled')
7474
ok($btn.hasClass('disabled'), 'btn has disabled class')
7575
start()
7676
stop()
7777
$btn.bootstrapButton('reset')
78-
equal($btn.html(), '', 'btn text equals ""')
7978
setTimeout(function () {
79+
equal($btn.html(), '', 'btn text equals ""')
8080
ok(!$btn[0].hasAttribute('disabled'), 'btn is not disabled')
8181
ok(!$btn.hasClass('disabled'), 'btn does not have disabled class')
8282
start()

0 commit comments

Comments
 (0)