Search code examples
backbone.jsbackbone.js-collections

Backbone.js async calls


I've been searching about this and haven't found an answer yet.

I found out that you can use async: true when calling fetch on Backbone, which isn't mentioned in its website. Can other methods, such as save, create, etc., be used with async too?


Solution

  • Have a look at Backbone.sync documentation :

    Backbone.sync is the function that Backbone calls every time it attempts to read or save a model to the server. By default, it uses jQuery.ajax to make a RESTful JSON request and returns a jqXHR.

    It means you can use all jQuery.ajax options on you requests, and you can indeed set an async option (defaults to true) on save/create