2013-05-09 30 views
2

我試圖摧毀骨幹模型,即使在服務錯誤時它也被破壞。骨幹模型甚至在服務錯誤時被破壞

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

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

}); 

在上述情況下,從集合中刪除模型是否是成功/錯誤。

假設這個銷燬回調失敗,模型不應該從集合中刪除。這怎麼能實現?

回答

3

通行證{等待:真正}如果你想等待服務器從集合刪除模型前作出迴應:

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

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

}); 
+0

謝謝你,但我怎麼能有這方面的超時? – user1184100 2013-05-10 07:11:36

+0

是否想在某個超時後從集合中刪除模型?或處理請求超時? – Protostome 2013-05-10 07:24:17

+0

它將被請求超時。 – user1184100 2013-05-10 08:44:11