如何确定Twitter引导组件事件的来源
How do I determine the source of a Twitter Bootstrap component event?
如果我在一个元素上使用工具提示和popover Twitter Bootstrap Javascript组件,我如何确定哪个组件触发了"显示"事件?
例如:
$("#button").tooltip();
$("#button").popover();
$("#button").on("shown", function(event) {
// I need to do some (flash) stuff that's specific to the popover content,
// the shown event is fired for both the tooltip and popover but doesn't
// appear to include any useful information about the context of the event.
// How do I determine if the popover component fired the event? The event.target
// is useless because it points to #button.
// The best I've come up with is to check if the element I'm interested in
// is visible but I'm assuming this will have issues if the popover component
// is animated...
if ($(".popover .thingy").is(':visible')) {
}
});
由于它使用jQuery,我相信事件表示的当前元素只是:
this
或者,
$(this) // to do jQuery operations on it
如果你想检查它是否可见:
if ($(this).is(":visible")) { ... }
相关文章:
- 如何向onClick事件处理程序传递一个接受参数的函数,并且仍然将该函数绑定到组件's”;这个“;上下文
- 单元测试:使用酶模拟父组件中子组件的点击事件
- React/flux - 子组件用户事件 - 是否应通过调度程序路由所有内容
- React:如何侦听子组件事件
- 将事件绑定到其他UI组件's函数,在Kendo MVVM中
- 如何更新angular2中组件之间的事件数据
- 点击tpl链接时,ExtJS 4.2自定义组件触发事件
- 反应:在嵌套组件上冒泡点击事件
- 如何根据其他组件中的事件更新组件URL
- 使用Ember中的组件生命周期事件
- 如何将事件绑定到模式对话框上的组件
- 将事件处理程序推送到父组件
- 通知全局事件组件的最佳方式
- React 渲染一个组件会触发 onClick 事件
- Web组件,添加Shadow DOM事件
- Extjs 4,事件处理,范围,自定义组件
- Gwd自定义组件及其事件处理程序
- 处理Twitter Flight组件的多个实例的事件
- React鼠标事件在没有监听它们的组件上触发
- Angular 2 ES6/7事件发射器更新其他组件