我正在建立一个 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 中,附加到按钮的操作不会触发,而附加到链接的操作会触发。在执行过程中进行的一些探索表明按钮上的单击处理程序没有触发,尽管它肯定已经设置好了。
关于为什么会这样(发生)的任何想法?谢谢!