带有ember.js的简单提交按钮

时间:2014-06-02 21:02:31

标签: ember.js form-submit

我是ember的新手,只想展示一个提交按钮原型。似乎没有提交操作,因此我在app.js文件中使用以下脚本:

 Ember.ObjectController.extend({
 actions: {
 submit: function() {
 this.get('content').save(); 
 }

HTML如下:

<form {{action "submit" on="submit"}}>
        {{input value=""}}  <button type="submit" id="button">nubmit name</button>
</form>

然而,在我的javascript控制台中,我收到以下错误:

 Error: Nothing handled the action 'submit'. If you did handle the action, this error can be caused by returning true from an action handler in a controller, causing the action to bubble.
  return params[this.name];

这是因为我的操作是分配给表单而不是按钮本身吗?

1 个答案:

答案 0 :(得分:0)

应在特定视图的路径或控制器中处理操作。

App.FooRoute = Em.Route.extend({
  actions:{
    submit: function(){}
  }
});


App.FooController = Em.Controller.extend({
  actions:{
    submit: function(){}
  }
});