Answer the question
In order to leave comments, you need to log in
What can replace the code construct?
There is an old proven code for synchronizing the backbone model with the database
var config = new App.Models.Config(option, data);
config.fetch().then(function () {
new App.Views.Config({model: config});
}, App.ajaxError);
config.once('sync', function(config) {
new App.Views.Config({model: config})
});
config.fetch();
Answer the question
In order to leave comments, you need to log in
Since reading from localStorage is synchronous, there is no need to use promises or callbacks:
var config = new App.Models.Config(option, data);
config.fetch();
new App.Views.Config({model: config});
var config = new App.Models.Config(option, data);
Promise.resolve(config.fetch()).then(function () {
new App.Views.Config({model: config});
}, App.ajaxError);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question