This may be a gross misunderstanding of the view concept in Ember…
But is it possible for a view to capture the action events in its template before they hit the controller or route?
Maybe this kind of behavior really belongs in a component?
Are views limited to the kind of events they can receive? e.g. the built in events (click, drag, mouseOver, etc)
Does a view like this make sense?
App.RequirementsView = Ember.View.extend({
templateName: 'requirementsview',
events: {
selectRequirement: function(requirement) {
// do something with the requirement
// Then send it along to an event in the controller
this.get('controller').send('selectRequirement', requirement);
},
resetRequirements: function() {
this.get('controller').send('resetRequirements');
}
}
});
In the template imagine you have something like this
Some buttons or
{{#each}}
<button {{action "selectRequirement" this }}>Select Requirment</button>
{{/each}}
<button {{action "resetRequirements" }}>Reset Requirments</button>
Or links
{{#each}}
<a {{action "selectRequirement" this}} href="#"> Select {{ name }} </a>
{{/each}}
<a {{action "resetRequirements"}} href="#"> Reset Requirments </a>