spine / spine

Lightweight MVC library for building JavaScript applications
http://spine.github.io
MIT License
3.66k stars 426 forks source link

Extend POST/DELETE fix from 1.6.0 to PUT calls #606

Open wschmrdrNS opened 8 years ago

wschmrdrNS commented 8 years ago

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.

aeischeid commented 8 years ago

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.