I have this posts.hbs:
{{#each model as |post|}}
<a href="#" {{action 'openWriteModal' post}}>
<h3>{{post.title}}</h3>
{{post.text}}
{{post.author.name}}
</a>
{{/each}}
Then I open my write-modal.hbs:
{{input value=model.title size="40" escape-press='close'}}
{{model.author.name}}
{{input value=model.text size="70" escape-press='close'}}
<button {{action 'close'}}>Close</button>
<button {{action 'save' model}}>Save</button>
Now, this is my components/write-modal.js:
import Ember from 'ember';
export default Ember.Component.extend({
actions: {
close: function() {
return this.sendAction('close');
},
save(model) {
model.set("text", model.get("text"));
model.save().then(this.sendAction('close'));
}
}
});
but I got this error: "Uncaught TypeError: model.save is not a function"
How to fix this?
Aucun commentaire:
Enregistrer un commentaire