动作处理程序不适用于视图本身 [英] Action Handlers Not Working on View itself

查看:27
本文介绍了动作处理程序不适用于视图本身的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

动作处理程序不直接作用于视图实例吗?

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.

示例 jsFiddle:http://jsfiddle.net/t3wdG/

Sample jsFiddle: http://jsfiddle.net/t3wdG/

更新:

我的目标是委托给 parentView 上的特定功能(在这种情况下是撤消,重做).我有 buttonView 的原因是因为点击每个按钮,我想对它做一些事情,例如向它添加一个 css 类.

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.

使用这种方法可以吗?

这是更新的 jsFiddle:http://jsfiddle.net/xvkgk/

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

推荐答案

好吧,我不认为有内置的 ember 方法可以做到这一点,但请检查这个 jsfiddle,它似乎按您的预期工作:http://jsfiddle.net/xvkgk/8/

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/

这篇关于动作处理程序不适用于视图本身的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆