amulous
amulous

Reputation: 732

How to prevent event bubbling for custom events in a Backbone application?

I have two views - ItemView and CardView -

In card view, I trigger a global event of ItemView as -

self.eventBus.trigger('dragEvent', {
       toId: moveToId,
       fromId: moveFromId,
       id: itemId,
       e: event
       });

This event trigger is handled by 'onDragEvent' function in ItemView as-

onDragEvent:  function(options) {
   ...     
 }

The dragEvent is bubbling up. How do I avoid it?

Upvotes: 1

Views: 234

Answers (1)

davkutalek
davkutalek

Reputation: 387

@muistooshort may be correct when it comes to triggering an Event module like that. However, you can stop a View event from bubbling with event.stopImmediatePropagation();

Upvotes: 1

Related Questions