1

我正在建立一个 Bootstrap “拆分按钮”模式,它看起来像这样:

<div class="btn-group">
  <button class="btn btn-small btn-primary">
    <a tabindex="-1" href="#" class="ajax-modal" 
       data-target="modal_vr-comment-form" data-backdrop="true" 
       data-controls-modal="res-modal" data-keyboard="true" 
       url="/some-url">Do the thing</a>
  </button>
  <button class="btn btn-small dropdown-toggle btn-primary" data-toggle="dropdown">
    <span class="caret"></span>
  </button>
  <ul class="dropdown-menu pull-right">
    <li><a tabindex="-1" href="#" class="ajax-modal" 
           data-target="modal_vr-comment-form" data-backdrop="true" 
           data-controls-modal="res-modal" data-keyboard="true"
           url="/some-url">Do the thing</a></li>
    <li><a tabindex="-1" href="/comment/something-else">Do something else</a></li>
    <li><a tabindex="-1" href="#" class="ajax-modal" 
           data-target="modal_unhide-people" data-backdrop="true" 
           data-controls-modal="res-modal" data-keyboard="true" 
           url="/comment/do-another-thing">Do another thing...</a></li>
  </ul>
</div>

这里有趣的是,“做这件事”动作以两种方式呈现:作为单击主按钮时要执行的动作,以及作为选择下拉菜单中的项目时要执行的动作。这些操作<a>通过一些 javascript init-ing 设置为拆分按钮中标签上的点击处理程序。

这两个操作在 Chrome 和 Safari 中都可以正常工作。但是,在 Firefox 中,附加到按钮的操作不会触发,而附加到链接的操作会触发。在执行过程中进行的一些探索表明按钮上的单击处理程序没有触发,尽管它肯定已经设置好了。

关于为什么会这样(发生)的任何想法?谢谢!

4

2 回答 2

2

或多或少找到它:Twitter Bootstrap 按钮在 IE8 中无响应有一种工作方法。而不是将按钮格式化为:

  <button class="btn btn-small btn-primary">
    <a tabindex="-1" href="#" class="ajax-modal" 
       data-target="modal_vr-comment-form" data-backdrop="true" 
       data-controls-modal="res-modal" data-keyboard="true" 
       url="/some-url">Do the thing</a>
  </button>

将其作为<A>与适当按钮样式类的纯链接:

<a tabindex="-1" href="#" class=" btn btn-small btn-primary ajax-modal" 
   data-target="modal_vr-comment-form" data-backdrop="true" 
   data-controls-modal="res-modal" data-keyboard="true" 
   url="/some-url">Do the thing</a>

外观相同,在 Firefox、IE 和 Opera(两个平台)中运行良好。唷。

于 2012-10-25T20:01:03.540 回答
0

我在 2019 年遇到了同样的问题(Bootstrap 4.3.1,Firefox Quantum 69.0),发现这篇 2011 年的帖子为我解决了这个问题:只需删除模态的动画(从父 div 中删除“fade”类) . 原帖在这里:http ://chapter31.com/2011/10/27/twitter-bootstrap-modal-not-working-in-firefox/

于 2019-09-05T13:34:27.840 回答