vendredi 18 mars 2016

Overwrite model's save

I try to overwrite an ember-data model's save function:

models/client.js

export default DS.Model.extend({
  billingAddress: DS.belongsTo('address'),
  //...
  save: function(...arg){
    var _this = this;
    this.get('billingAddress').then(billingAddress=>{
      return billingAddress.save().then(function(){
        return _this._super(arg);
      });
    })

  }
});

Somewhere else I do

record.save().then(function(){
  // show a message
});

I am getting the following error:

Uncaught TypeError: Cannot read property 'then' of undefined

Aucun commentaire:

Enregistrer un commentaire