I need to call a fetch with a synchronous call,
I know with jquery ajax I can use {async: false}
can I pass this option to fetch function ?
Backbone. js gives structure to web applications by providing models with key-value binding and custom events, collections with a rich API of enumerable functions, views with declarative event handling, and connects it all to your existing API over a RESTful JSON interface.
js Event once() The event once method is just like event on method but it causes the bound callback to only fire once before being removed.
You can use the Backbone. Model without jQuery, but Backbone.
So the short answer is yes, you can simple call fetch function with param
{async:false}.
Actually backbone fetch method internally calls ajax. So you can pass any ajax options to backbone fetch method.
collection.fetch({
// ajax options
async: false, // by default it is true
success: function(collection, response, options){
console.log("success")
},
error: function(collection, response, options){
console.log("error")
}
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With