Last Updated: February 25, 2016
·
1.817K
· jesseobrien

Backbone JS PATCH Syncing

When using the new PATCH functionality in backbone.js and you want it to update the model with any changes that have happened server-side (say two users may be editing one form or something) there is a parse directive you can use.

MyModel.save(key, value, { patch: true, parse: true });

So long as you return the full model back in the PATCH request, it will parse that model and add any changes to MyModel.changed once the request succeeds.

Have a fresh tip? Share with Coderwall community!

Post
Post a tip
Did you know?

JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.

Security insights from Cside