gpt4 book ai didi

jquery - 即使出现服务错误,主干模型也会被破坏

转载 作者:行者123 更新时间:2023-12-01 03:43:12 27 4
gpt4 key购买 nike

我试图破坏主干模型,即使出现服务错误它也会被破坏。

View : 
this.listenTo(this.collection, 'remove', function() {});

this.model.destroy({
success : function(model) {
/* remove the li view */
},
error : function() {}

});

在上述情况下,无论模型是成功还是错误,模型都会从集合中删除。

假设如果此销毁回调失败,则不应从集合中删除模型。如何实现这一目标?

最佳答案

如果您想在从集合中删除模型之前等待服务器响应,请传递 {wait: true}:

View : 
this.listenTo(this.collection, 'remove', function() {});

this.model.destroy({
success : function(model) {
/* remove the li view */
},
error : function() {},
wait:true

});

关于jquery - 即使出现服务错误,主干模型也会被破坏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16464518/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com