jeudi 8 janvier 2015

destroyRecord() does not trigger model listeners (Ember Beta)

Ember Version: 1.10.0-beta.3, Ember Data: 1.0.0-beta.12


I have several computed properties with .property('model'). But when I do destroyRecord() in a controller action the property function does not fire. I can force that by notifyPropertyChange() and then function indeed fires, but then template doesnt get rerendered for some reason.


Whole action code looks like this:





cleanSpot: function(id){
var id = this.get('clickedId');
var _this = this;

this.store.find('spot', id).then(function(spot){

return spot.destroyRecord();

})
.then(function(){
// _this.notifyPropertyChange('model');
var popupController = _this.get('controllers.popup');
popupController.set('isVisible',false);
});
},



Interesting is, that this similar action to add a record, works just fine:





addSpot: function(style){
//WARNING: Security
var _this = this;
var data = {
x: this.get('hoveredX'),
y: this.get('hoveredY'),
city: this.get('city'),
style: style
};
this.store.createRecord('spot',data).save().then(function(){

}).catch(function(){
//rollback?
});

},



I started to get these issues after I updated to Ember Beta, but I guess its more likely that I am doing something wrong than that it is a bug.





Aucun commentaire:

Enregistrer un commentaire