Reputation: 7
Inside
Songs.IndexRoute = Ember.Route.extend({})
we have some events, which are trigerred with {{action selRow}}
in HTML file.
They do abstract events, but can't define themselves.
In this example I have a table and need to select rows by click and delete selected rows hitting the button, but can't figure out how can do it.
Upvotes: 0
Views: 121
Reputation: 19050
Pass the model object being selected as argument to the selRow event:
{{action selRow this}}
Now use IndexController to keep track of selected songs. Use route's model hook to start the array empty:
Songs.IndexRoute = Ember.Route.extend({
model: function() {
return Ember.A()
},
});
Now the event's make more sense as controller methods:
Songs.IndexController = Ember.ArrayController.extend({
pushMe: function(){
this.forEach(function(song) {
console.log('deleting song: ', song.toString());
});
},
selRow: function(song) {
console.log('I am selected', song, song.toString());
this.pushObject(song);
}
});
See modified fiddle here: http://jsfiddle.net/HwCx3/
Upvotes: 1