垃圾中的删除记录不会从集合中删除 [英] Deleted record in ember is not removed from collection
问题描述
显示
页面,该记录与删除
按钮,与控制器相关联: destroy:function(){
this。 content.deleteRecord()
this.store.commit()
this.transitionTo('usersIndex')
}
我知道记录被删除,我可以看到它在服务器上删除。 AJAX请求成功。但是,该记录仍然显示在索引页面上。如果我从服务器进行硬刷新,现在已经不在了。
我的路由器为 usersIndex
是以下内容:
App.UsersIndexRoute = Ember.Route.extend({
model:function(params){
返回App.Users.find();
},
setupController:function(controller,model){
controller.set('content',model);
}
});
调用deleteRecord后,您必须将其保存为ember数据。
destroy:function(){
this.content.deleteRecord()
this.content。获得( '请将isDeleted');
this.content.save()
this.store.commit()
this.transitionTo('usersIndex')
}
或者您可以起诉destroyRecord,它从后端和余烬数据中删除记录
destroy:function(){
this.content.destroyRecord()
this.transitionTo('usersIndex')
}
希望这有帮助!
I am building a simple CRUD app. I have a list of records fetched from the server, click on the first and I am on the show
page for that record with a delete
button that ties into this action on the controller:
destroy: function() {
this.content.deleteRecord()
this.store.commit()
this.transitionTo('usersIndex')
}
I know the record is deleted, I can see it deleted on the server. The AJAX request is successful. However, the record still shows up on the index page. If I do a hard refresh from the server it is now gone.
My Router for usersIndex
is the following:
App.UsersIndexRoute = Ember.Route.extend({
model: function(params) {
return App.Users.find();
},
setupController: function(controller, model) {
controller.set('content', model);
}
});
After calling deleteRecord you must save it for the ember data.
destroy: function() {
this.content.deleteRecord()
this.content.get('isDeleted');
this.content.save()
this.store.commit()
this.transitionTo('usersIndex')
}
Or alternatively you can sue destroyRecord which deleted thh record from both backend and ember data
destroy: function() {
this.content.destroyRecord()
this.transitionTo('usersIndex')
}
Hope this helps !
这篇关于垃圾中的删除记录不会从集合中删除的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!