Bootstrap JQuery加载状态自动禁用按钮,如何使其他状态执行相同操作 [英] Bootstrap JQuery loading state auto disables button, how to get other states to do the same

查看:112
本文介绍了Bootstrap JQuery加载状态自动禁用按钮,如何使其他状态执行相同操作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

$this.button('loading')在运行时自动向其中添加disabled类,我想创建第二个版本的$this.button('loading').因此,在加载按钮中可以有2个文本版本.

$this.button('loading') auto adds disabled class to it while it's running, I want to create a second version of $this.button('loading'). So I can have 2 versions of text in a loading button.

如果我使用continueloading2之类的自定义条目,它将应用文本,但在该时间段内不应用disabled

If I use a custom entry such as continue or loading2, it applies the text but does not apply the disabled class during that timeframe

示例

http://www.bootply.com/129005#

我尝试过只是添加attr并更改按钮的html,这是可行的.但是表格实际上永远不会完成,只是挂在第二个文本上.

I've tried just doing an attr add and changing the html of the button, which works. But the form actually won't ever complete, it just hangs on the second text.

文本的第二部分需要保留,直到它调用的php页面完成为止(这在上面的示例中现在可以正常使用,除了在continue部分中可以单击按钮之外.

The second portion of text needs to stay until the php page it calls gets completed (which works fine right now with the example above, besides the button is clickable during the continue portion.

推荐答案

根据引导程序文档 ,超时后第二次调用btn.button(...)将重置按钮状态:

According to the bootstrap docs, the second invocation of btn.button(...) after the timeout will reset the button state:

$().button(string)

重置按钮状态-将文本交换为任何数据定义的文本状态.

Resets button state - swaps text to any data defined text state.

相反,您只想在按钮的现有状态下修改其文本,即:

Instead you just want to modify the text of the button in it's existing state, i.e:

setTimeout(function(){
    btn.prop('value', 'still going..')  
}, 1000);

http://www.bootply.com/129028

这篇关于Bootstrap JQuery加载状态自动禁用按钮,如何使其他状态执行相同操作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆