var homeView = Backbone.View.extend({
el: $("#main_container"),
initialize: function(){
_.bindAll(this, 'render');
},
render:function(){
$.get('/home', {}, function(data){
console.log(data);
var tpl = _.template(home_container_temp, {});
this.el.html(tpl);
});
}
});
I want to do a ajax GET request, and then set the data. But I can’t do it because I get:
Uncaught TypeError: Cannot call method 'html' of undefined
thisinside the$.get()is not refering to the view.Try: