gpt4 book ai didi

javascript - Bootstrap绑定(bind)方式

转载 作者:行者123 更新时间:2023-12-03 11:53:40 25 4
gpt4 key购买 nike

我正在查看 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com