Action handlers not working on the view itself

Do action handlers work directly in view instances?

Instead of attaching an action handler in the view, I want to bind it directly to the whole view.

JsFiddle example: http://jsfiddle.net/t3wdG/

UPDATE:

My goal is to delegate certain functions (undo, redo in this case) to parentView. The reason I have a buttonView is because when I click on each button, I want to do something with it, for example, add a css class to it.

Thus, I want all my buttons to add a class to themselves by click, and then delegate individual functions in the parent view.

Can this approach be used?

Here is the updated jsFiddle: http://jsfiddle.net/xvkgk/

0
source share
2 answers

Ok, I don’t think there is a built-in ember way to do this, but check this jsfiddle, it works the way you expect: http://jsfiddle.net/xvkgk/8/

+1
source

The recommended solution is to create a custom subclass of the view. Then you can add a click function a subclass that will handle click events automatically.

+1
source

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


All Articles