diff --git a/js/button.js b/js/button.js index b3e944c591..1b9a2f23b7 100644 --- a/js/button.js +++ b/js/button.js @@ -35,10 +35,10 @@ if (data.resetText == null) $el.data('resetText', $el[val]()) - $el[val](data[state] == null ? this.options[state] : data[state]) - // push to event loop to allow forms to submit setTimeout($.proxy(function () { + $el[val](data[state] == null ? this.options[state] : data[state]) + if (state == 'loadingText') { this.isLoading = true $el.addClass(d).attr(d, d) diff --git a/js/tests/unit/button.js b/js/tests/unit/button.js index bd431d5467..e629918b1e 100644 --- a/js/tests/unit/button.js +++ b/js/tests/unit/button.js @@ -33,9 +33,9 @@ $(function () { var $btn = $('') equal($btn.html(), 'mdo', 'btn text equals mdo') $btn.bootstrapButton('loading') - equal($btn.html(), 'fat', 'btn text equals fat') stop() setTimeout(function () { + equal($btn.html(), 'fat', 'btn text equals fat') ok($btn[0].hasAttribute('disabled'), 'btn is disabled') ok($btn.hasClass('disabled'), 'btn has disabled class') start() @@ -46,16 +46,16 @@ $(function () { var $btn = $('') equal($btn.html(), 'mdo', 'btn text equals mdo') $btn.bootstrapButton('loading') - equal($btn.html(), 'fat', 'btn text equals fat') stop() setTimeout(function () { + equal($btn.html(), 'fat', 'btn text equals fat') ok($btn[0].hasAttribute('disabled'), 'btn is disabled') ok($btn.hasClass('disabled'), 'btn has disabled class') start() stop() $btn.bootstrapButton('reset') - equal($btn.html(), 'mdo', 'btn text equals mdo') setTimeout(function () { + equal($btn.html(), 'mdo', 'btn text equals mdo') ok(!$btn[0].hasAttribute('disabled'), 'btn is not disabled') ok(!$btn.hasClass('disabled'), 'btn does not have disabled class') start() @@ -67,16 +67,16 @@ $(function () { var $btn = $('