javascript - Bootstrap绑定(bind)方式

标签 javascript jquery twitter-bootstrap-3

我正在查看 Bootstrap 'dropdown'模块,并且无法集中精力处理某些事情。

基于该代码,需要通过调用它来显式启动该模块,例如

$(element).dropdown({options..})

然而,如果你只是给任何元素一个带有 [data-toggle="dropdown"] 的属性

相关模块启动,从未进入构造函数/插件函数。

有人可以向我解释一下这个巫术吗?

最佳答案

答案:

http://api.jquery.com/on/#event-names

An event name can be qualified by event namespaces that simplify removing or triggering the event. For example, "click.myPlugin.simple" defines both the myPlugin and simple namespaces for this particular click event. A click event handler attached via that string could be removed with .off("click.myPlugin") or .off("click.simple") without disturbing other click handlers attached to the elements. Namespaces are similar to CSS classes in that they are not hierarchical; only one name needs to match. Namespaces beginning with an underscore are reserved for jQuery's use.

Bootstrap 使用“事件名称间距”绑定(bind)点击事件。行(我相信是816)

.on('click.bs.dropdown.data-api', toggle, Dropdown.prototype.toggle)  

关于javascript - Bootstrap绑定(bind)方式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25699522/

相关文章:

jquery - Bootstrap Popover : Hover/Click and Close on Outside Click, 但恢复到悬停模式

javascript - React Native - Firestore : Possible Unhandled Promise Rejection Can't find variable atob

php - 一起使用javascript和php来验证

javascript - 如何合并选项数组

css - Twitter Bootstrap : Modifying pixel width thresholds for col-sm

jquery - X-editable datepicker 一直在同一个地方弹出 - 如何让它在实际日期字段旁边弹出?

c# - 避免 JavaScript 和 C# 中的重复逻辑

javascript - 不用JS改变背景颜色

javascript - 服务器端之前的客户端验证

javascript - 函数完成后触发