Backbone.sync
This is responsible to handle connections between a RESTful server and the Backbone application is the Backbone.sync module. It transforms the fetch()
and save()
operations into HTTP requests:
fetch()
is mapped as aread
operation. This will makeGET
to the theurlRoot
attribute with the model ID for a model or theurl
attribute for a collection.save()
is mapped as acreate
orupdate
operation; it depends on theisNew()
method:- This will be mapped as
create
if the model does not have an ID (isNew()
method returntrue
). A POST request is executed. - This will be mapped as
update
if the model already has an ID (isNew()
method returnsfalse
). A PUT request is executed.
- This will be mapped as
destroy()
is mapped as adelete
operation. This will make DELETE to the ...
Get Mastering Backbone.js now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.