出口行动

时间:2014-03-10 10:48:13

标签: ember.js

我正在尝试在我的toolbar商店中实施搜索功能:

application.hbs

<section class="toolbar">
    {{outlet toolbar}}
</section>

{{/if}}

<section class="content">
    {{outlet}}
</section>

路线

renderTemplate: function() {

  // render all posts
  this.render('organization/customers', {
    into: 'application'
  });

  // render toolbar
  this.render('organization/toolbar', {
    into: 'application',
    outlet: 'toolbar'
  });
}

toolbar.hbs

<button {{action 'foo'}}>foo</button>

查看

Docket.OrganizationCustomersView = Ember.View.extend(Docket.FloatingLabelsMixin, {
  templateName: 'organization/customers',
  actions: {
    foo: function() {
      console.log('bar')
    }
  }
});

但是操作没有被触发,我的控制台中没有输出。我应该在哪里宣布行动?我想为我的所有模板实现一个搜索功能,所以在每个视图中定义动作都是一种糟糕的方式。

1 个答案:

答案 0 :(得分:2)

将其添加到与该路线关联的控制器。

或者将其添加到您已定义renderTemplate的路线。

http://emberjs.jsbin.com/lipoh/1/edit

相关问题