Bootstrap 3单选按钮两次切换 [英] Bootstrap 3 Radio Buttons Double Toggling

查看:195
本文介绍了Bootstrap 3单选按钮两次切换的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Bootstrap 3单选按钮.除了从未选择input元素之外,其他一切似乎都正常运行.

I am trying to use Bootstrap 3 radio buttons. Things seem to be working fine, other than the input elements are never selected.

我发现click.bs.button.data-api事件被触发一次,并且仅调用一次$btn.button('toggle').但是,$.fn.button会以某种方式触发两次.结果,Button.prototype.toggle正确地将输入设置为选定状态,然后取消选择它.

I found that the click.bs.button.data-api event is triggered once, and that calls $btn.button('toggle') only once. However, $.fn.button is somehow triggered twice. As a result, Button.prototype.toggle correctly sets the input to its selected state and then deselects it.

为什么$.fn.button可以两次运行?

推荐答案

在尝试在JS Fiddle上重现该问题之后,我能够确定问题的根源.

After I tried to reproduce the issue on JS Fiddle, I was able to identify the source of the issue.

这是我正在从Bootstrap 2更新到Bootstrap 3的一个应用程序.有一个包含Bootstrap 2的大型JS库文件.将其与Bootstrap 3一起运行会导致toggle方法运行两次,从而使该方法无效选择.

This was an application that I was updating from Bootstrap 2 to Bootstrap 3. There was a big JS libraries file that contained Bootstrap 2. Running that one along with Bootstrap 3 caused the toggle method to be run twice, thus invalidating the selection.

删除所有Bootstrap 2代码后,错误消失了.

The error went away after removing all of the Bootstrap 2 code.

这篇关于Bootstrap 3单选按钮两次切换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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