My App uses Fixture data (will port to Localstorage later) and I need to implement 'save' method depending on a user click. The user click is an action that maps to the View and from therein the view, it gets transferred to the controller in order to persist info to the model, essentially the template has:
<button {{action 'save' this target='view'}}>Save</button> <!-- note that the 'this' keyword I am sending corresponds to a specific instance of the model that is in a collection, done using an {{#each model}} loop
The view has
actions:{
save:function(card){
// perform some UI activity
this.get('controller').send('save',card); // card representing 'this'
}
}
The controller has:
actions:{
save:function(card){
console.log("controller reached"); // does execute
card.save(); // spits out an error
}
}
Everything works fine however the card.save() method call does not work in the controller. I mean, all I am trying to do is to persist the specific 'card' to my data, but it keeps spitting:
Uncaught TypeError: Object # has no method 'save'
What am I missing here ?
Side notes:
- The Controller returns a collection of models
- The corresponding'view' for the controller also has the 'edit' partial loaded in it. So when the user chooses to 'edit' a specific model, it doesn't transition into a different URL, rather it loads the 'editing' form within the same URL.
- This means that the model in this specific controller is essentially the collection and I only want to save the specific model that is being edited.