jQuery Bootstrap 3 中的加载状态按钮
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19069759/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Loading state button in Bootstrap 3
提问by kanarifugl
I'm new to Bootstrap 3. Can't figure out how to activate the loading state button function. My code below is from the documents on getboostrap.com.
我是 Bootstrap 3 的新手。无法弄清楚如何激活加载状态按钮功能。我下面的代码来自getboostrap.com上的文档。
<button type="button" data-loading-text="Loading..." class="btn btn-primary">
Loading state
</button>
Dropdowns works fine so I guess the problem is somewhere else?
下拉菜单工作正常,所以我猜问题出在其他地方?
回答by Ionic? Biz?u
You need to detect the click from js side, your HTML remaining same. Note: this method is deprecated since v3.5.5 and removed in v4.
您需要检测来自 js 端的点击,您的 HTML 保持不变。注意:此方法自 v3.5.5 起已弃用,并在 v4 中删除。
$("button").click(function() {
var $btn = $(this);
$btn.button('loading');
// simulating a timeout
setTimeout(function () {
$btn.button('reset');
}, 1000);
});
Also, don't forget to load jQuery and Bootstrap js (based on jQuery) file in your page.
另外,不要忘记在页面中加载 jQuery 和 Bootstrap js(基于 jQuery)文件。