Blaze Template event and class names

I just wanted to know if there is a way to delegate Template specific events.

Usually, Blaze Template event delegates automatically all events to children Templates (or rather Views) and not to the parent View. But what if the given class already exists in the parent ? Of course you can solve this issue by creating a well thought namespacing, but what if the given parent class comes from a package ? Is there a way to make something like this:{
    "click this.className": function(){
    // event

Even if the given class already exists in the parent or in the sibling, it’s still not visible for the template - your template won’t see it used on any elements that are not a part of this Template + children. So your className is already this.className, no need to worry.

Personally, I use manuel:viewmodel and specify event bindings at the particular element level, not class level. This way my event is registered only for elements I directly specified.

1 Like

The more I dig into reusable components and MVC, the more I realize manual-viewmodel is necessary for big applications.

Thank you for the answer, you have been quite active lately (always the same people here :grin:)

It’s certainly very helpful to keep medium and large Blaze apps well organized and makes them easier to maintain, as long as you keep using it in an uniform manner. And it makes my code twice shorter, which I love too.