Reputation: 34168
Do action handlers not work directly on view instances?
Instead of attaching an action handler within the view, I want to attach it directly on the entire view itself.
Sample jsFiddle: http://jsfiddle.net/t3wdG/
UPDATE:
My goal is to delegate to specific functions (undo, redo in this case) on the parentView. The reason I have the buttonView is because on click on each button, I want to do something to it, for example add a css class to it.
So in effect, I want all my buttons to add a class to themselves on click and then delegate to separate functions on the parent view.
Is this possible using this approach?
Here is the updated jsFiddle: http://jsfiddle.net/xvkgk/
Upvotes: 0
Views: 428
Reputation: 5056
The recommended solution is to make a custom view subclass. You can then add a click
function the subclass that will handle click
events automatically.
Upvotes: 1
Reputation: 12011
Ok, I don't think there is a built in ember way to do that, but check this jsfiddle, it seems work as you expect: http://jsfiddle.net/xvkgk/8/
Upvotes: 1