Reputation: 2362
I have very simple scenario. I retrieve particular instance of a model
model: function(params) {
return this.store.findRecord('project', params.id);
},
and I provide form for editing it:
<h2>Edit project {{model.title}}</h2>
<label>Project title</label>
<br/>
{{input value=model.title size="50"}}
<label>Project description</label>
{{input value=model.description size="50"}}
<label>Project explanation</label>
{{textarea value=model.full_description cols="50" rows="6"}}
{{#bs-button action="saveProject"}}Save{{/bs-button}}
Then in saveProject
action handler I need to have a reference to model that was edited. How can I retrieve it?
Thanks in advance.
Upvotes: 0
Views: 612
Reputation:
Reference the model property on the controller:
// controller.js
actions: {
saveProject() {
this.get('model') . save();
}
}
Upvotes: 1
Reputation: 11293
If you check the api docs for the bs-button
component you can see that the value property is sent along with the action, in your case you would just need to set value=model
:
{{#bs-button action="saveProject" value=model}}Save{{/bs-button}}
And your saveProject
action would look like:
saveProject: function(record) {
// Handle the saving here
}
Upvotes: 1