jeudi 4 août 2016

ember - Failing to save a new model

I have a very simple author model with one field, name. I have a form in my authors/new template that calls the action save when it is submitted.

<form >
  <br>
  <input type="submit" value="Save">

</form>

In my route for authors/new I define the model to create a record for author, then define the action save to save this model.

import Ember from 'ember';

export default Ember.Route.extend({
    model() {
        return this.store.createRecord('author');
    },
    actions: {
        save() {
            this.get('model').save();
        }
    }
});

However when I click the save button, I get the following error in my console. Uncaught TypeError: this.get(...).save is not a function. Can anyone help me out as to what I'm doing wrong?




Aucun commentaire:

Enregistrer un commentaire