mardi 25 octobre 2016

Ember's model.save is not a function from the action but is from a template

I have a button in a template with an action:

// template
<button class="btn btn-danger" >

And its route:

// route
actions: {
  eventCancel(model) {
    model.set('action', 'cancel');
    model.save().then(function () {
      this.transitionTo('event', model.id);
    }.bind(this));
  }
}

I can do from the template and see the function is there.

Doing the same thing from the action's parameter results in undefined.

They have the same identifier. In my case __ember1477392164713: "ember697" is present in the log message when logged from the template or the action. So it would seem to be the exact same object. It just loses its ability to be saved somehow.

What's going on here? I thought passing the model from the template to the action should work?

I also tried getting the model with this.controller.get('model'); inside the action to no avail.




Aucun commentaire:

Enregistrer un commentaire