I’ve got a Backbone event that includes:
this.model.save()
.done(function(response) {
require(['models/countModel', 'views/countView'], function(cm, cv, response) {
console.log(response);
});
});
.fail(function(response) {
...
});
console.log(response) yields undefined. I need the response from the server so I can process the data. How do I get to it? But if I console.log() it above the require then I get to the response from the server. How do I pass it in? What I am doing does not work. I don’t think that’s how a require is intended to work, but I tried it.
You don’t need to pass response as reference with require, as it’s already defined when done is called. Change your require call to:
should do the trick!