Я не могу понять, почему this.model будет определен в view.intialize(), когда я запустил this.model.fetch(), но не в view.render().Магистральная модель не определена?
define([
'jquery',
'underscore',
'backbone',
'text!templates/example.html'
], function($, _, Backbone, exampleTemplate){
var exampleView = Backbone.View.extend({
el: $('body'),
initialize: function() {
this.model.set({ _id: this.options.user_id });
this.model.fetch({
success: this.render,
error: function(model, response) {
console.log('ERROR FETCHING MODEL');
console.log(model);
console.log(response);
}
});
},
render: function() {
console.log('HELLO FROM RENDER');
console.log(this.model);
console.log('GOODBYE FROM RENDER');
}
});
return exampleView;
});
Неужели 'this' получает отказ от ссылки при успешном вызове? Возможно, вам нужно связать его. – JaredMcAteer