mercredi 8 mars 2017

How to get id of created record in computed property?

I have competed property in component which observes model.events

formatedEvents: function () { doSomeStaff(); }.property('model.events')

And I have action which create event:

var event = this.get('store').createRecord('event', attr);
event.save().then((l) => {
  this.get('currentUser.events').then((_e)=> {
    _e.addObject(l);
  });
}).catch((err) => {
  lesson.deleteRecord();
  this.handleError(err);
});

Ember fires my computed property when record was created because there is id of new record is null. But I need to make Ember fires computed property after promise is fulfilled which returned save() then I will be able to get id in property.




Aucun commentaire:

Enregistrer un commentaire