Action Handlers Not Working on View itself

ぃ、小莉子 提交于 2019-12-20 06:29:58

问题


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/


回答1:


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/




回答2:


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.



来源:https://stackoverflow.com/questions/12815100/action-handlers-not-working-on-view-itself

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!