[英]How to prevent event bubbling for custom events in a Backbone application?
I have two views - ItemView and CardView - 我有两个视图-ItemView和CardView-
In card view, I trigger a global event of ItemView as - 在卡片视图中,我以-触发ItemView的全局事件-
self.eventBus.trigger('dragEvent', {
toId: moveToId,
fromId: moveFromId,
id: itemId,
e: event
});
This event trigger is handled by 'onDragEvent' function in ItemView as- 此事件触发器由ItemView中的“ onDragEvent”函数按以下方式处理:
onDragEvent: function(options) {
...
}
The dragEvent is bubbling up. dragEvent起泡了。 How do I avoid it? 如何避免呢?
@muistooshort may be correct when it comes to triggering an Event
module like that. @muistooshort在触发这样的Event
模块时可能是正确的。 However, you can stop a View
event from bubbling with event.stopImmediatePropagation();
但是,可以使用event.stopImmediatePropagation();
阻止View
事件冒泡event.stopImmediatePropagation();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.