Meteor Stop Event

I hooked up some basic click events using Meteor event maps .

How to stop event propagation after processing?

State meteorite documents that

Currently, event handlers are hooked using jQuery, and the event object you receive is a jQuery event object.

However, neither return false nor e.stopPropagation() seems to work.

+6
source share
2 answers

StopPropagation currently operates in a limited number of circumstances. To stop propagation between two handlers, the handlers must be specified on different templates, and there must be an intermediate DOM node container between the internal and external templates. The fix is ​​in development right now and will be included in an upcoming release.

Can you post the gist of your code so that I can make sure your specific case will be added?

As a workaround, you can try e.stopImmediatePropagation (), which is provided by jQuery and should contain any other handlers.

+7
source

I came across this question while researching this myself. The documentation for Blaze event cards is here .

For this task in a meteor, you need to consider 2 functions depending on what you want:

stopPropagation()

Prevention of the spread of the event (bubble) to other elements. Other event handlers corresponding to the same element are still running in this and other event cards.

stopImmediatePropagation()

Prevent the launch of all additional event handlers in this event, including other handlers in this event map, handlers reached by bubbling, and handlers on other event cards.

What I wanted was to stop bubbling and stop spreading to other Meteor event handlers. So event.stopImmediatePropagation() did the trick, and this is not a workaround as above.

+1
source

Source: https://habr.com/ru/post/914692/


All Articles