0
我更改爲主幹關係後,我的模型在我調用destroy()時停止工作。我必須確保當它在服務器上刪除成功時,將不會再有id客戶端,所以然後當我嘗試再次保存它時,我的模型不會請求PUT(更新) - 在服務器端拋出Record Not Found。銷燬服務器模型不更新id爲空
CoffeeScript的側
save: ->
if isBlank @model.get("text")
@model.destroy() # after success it still with same attributes including id!!
else
@model.save()
Rails的側
def destroy
@note = Note.find(params[:id])
@note.destroy
respond_with @note # callback is empty
end
錯誤的骨幹,關係吧? Backbone.js在銷燬後更新ID嗎?
感謝的人,我只是好奇爲什麼backbone.js在成功執行destroy()後不會清理你的id:/ – mateusmaso