spine / spine

Lightweight MVC library for building JavaScript applications

Home Page:http://spine.github.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Extend POST/DELETE fix from 1.6.0 to PUT calls

wschmrdrNS opened this issue · comments

In release 1.6, you added functionality that reverts the contents of a Model object if a POST or DELETE call fails. An update should be made to also revert the contents of a Model object if a PUT fails. Presently, even if the AJAX call fails, the model is still updated with the bad data.

Our present workaround is to store the old contents of the model (or do a find since, IIRC, it does a clone), restore the old contents, and re-save, because the model object is updated.

I agree this would be a good feature to add, at least as an option, but I do think this one needs to be made configurable. One because many people probably have their own approaches to solving the problem as is, and two, reverting for POST and DELETE doesn't take the local record out of sync with the remote in the same way as it might for a PUT, and in some cases you simply might not want to do that.