admin管理员组文章数量:1389762
I want have have a "Loading. . .
" whenever I click on the "Submit
" button. In this case, how e it did not display the "Loading. . .
" thingy? bootstrap 2.3.2
<input type="submit" data-loading-text="Loading..." disabled="disabled" style="" id="save" class="btn btn-primary " value="Submit" name="save">
Here's my JS:
$('#save').click(function() {
var btn = $(this);
btn.button('loading');
btn.button('reset');
});
I can't find any error in console either. What did I miss?
I want have have a "Loading. . .
" whenever I click on the "Submit
" button. In this case, how e it did not display the "Loading. . .
" thingy? bootstrap 2.3.2
<input type="submit" data-loading-text="Loading..." disabled="disabled" style="" id="save" class="btn btn-primary " value="Submit" name="save">
Here's my JS:
$('#save').click(function() {
var btn = $(this);
btn.button('loading');
btn.button('reset');
});
I can't find any error in console either. What did I miss?
Share Improve this question edited Aug 9, 2015 at 18:13 Siguza 24k6 gold badges55 silver badges99 bronze badges asked May 11, 2015 at 8:30 ZSMJZSMJ 992 silver badges5 bronze badges 4-
3
.button
? .. Sounds interesting..! perhaps you wanted.val()
instead? Also, this is a submit, you should prevent it's default value, else it will reload the document! ;) Something like that? jsfiddle/cmfc6qLL (the setTimeout is just for an example purpose, some kind of delay to show that both "loading" and "reset" are written) – briosheje Commented May 11, 2015 at 8:31 - .val() works. Thanks! – ZSMJ Commented May 11, 2015 at 8:35
- despite the official documentation talks about "button.js" (getbootstrap./javascript) I would rather remend use to use some pure jQuery solutions for such problems, it is just enough ;) – briosheje Commented May 11, 2015 at 8:36
- 1 you will never see the word 'loading', as you're also immediately changing it to 'reset'... Perhaps you want to do something before changing it to 'reset'? – toomanyredirects Commented May 11, 2015 at 8:39
2 Answers
Reset to default 1Try this:
$('#save').click(function() {
var btn = $(this);
btn.val(btn.data("loading-text")); setTimeout(function() {
btn.val('reset');
}, 2000);
});
<script src="https://ajax.googleapis./ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<input type="submit" data-loading-text="Loading..." style="" id="save" class="btn btn-primary " value="Submit" name="save">
Here's an example, you need to btn.val('loading...');
because you change the value of your input
. Here's a working demo.
本文标签: javascriptdataloadingtext not workingStack Overflow
版权声明:本文标题:javascript - data-loading-text not working - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744735370a2622295.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论