Javascript 使用escape键取消Ember TextView中的操作

Javascript 使用escape键取消Ember TextView中的操作,javascript,ember.js,Javascript,Ember.js,当用户按下输入字段中的escape键时,如何使Ember触发控制器动作 给定以下应用程序代码: App = Ember.Application.create(); App.IndexRoute = Ember.Route.extend({ model: function () { return {foo: "bar"}; } }); App.IndexController = Ember.ObjectController.extend({ actions: { d

当用户按下输入字段中的escape键时,如何使Ember触发控制器动作

给定以下应用程序代码:

App = Ember.Application.create();

App.IndexRoute = Ember.Route.extend({
  model: function () {
    return {foo: "bar"};
  }
});

App.IndexController = Ember.ObjectController.extend({
  actions: {
    done: function () {
      console.log("done");
    },
    cancel: function () {
      console.log("cancel");
    }
  }
});
以及以下HTML:

<body>
  <script type="text/x-handlebars" data-template-name="application">
    {{outlet}}
  </script>
  <script type="text/x-handlebars" data-template-name="index">
    {{input value=foo action="done" cancel="cancel"}}
  </script>
</body>

{{outlet}}
{{input value=foo action=“done”cancel=“cancel”}
我希望控制器中的取消操作会被触发,但我得到的是一个错误:
对象[object object]的属性“cancel”不是一个函数


用上面的代码来说明。我怎样才能做到这一点呢?

虽然没有很好的文档记录,但是看到了代码。。。

你应该这样定义你的把手

{{input value=foo enter='done' escape-press='cancel'}}

你阻止我回答一件愚蠢的事情。谢谢@eduI试图用diInsertElement和这个做其他愚蠢的事情。$()。继续,但我决定阅读代码并。。。