Slevin
Slevin

Reputation: 4232

Actions in outlets

I'm trying to implement a search function in my toolbar outlet:

application.hbs

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

{{/if}}

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

route

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>

view

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

But the action doesn't get fired and there's no output in my console. Where should I declare the action? I want to implement a search function for all my templates, so defining the action in every view is a bad way anayway.

Upvotes: 1

Views: 357

Answers (1)

Kingpin2k
Kingpin2k

Reputation: 47367

Add it to the controller associated with that route.

Or add it to the route where you have that renderTemplate defined.

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

Upvotes: 3

Related Questions