What function would you change to override Backbone.js’s default support for REST APIs?



Please explain why do you think this question should be reported?

Report Cancel

To override the default behavior on a per-model basis, you can set a custom function to “Model.sync”. To make the change global, you can set the custom function to “Backbone.sync”. Ideally, the “sync” function should handle four methods: “create”, “read”, “update”, and “delete”. The function receives the CRUD method name, the model itself, and an object with some additional options. Sometimes setting “Backbone.emulateJSON” to true can often do the job, in which case all you need to do is submit requests as “application/x-www-form-urlencoded” instead of “application/json”.

Please follow and like us:

About the Author