This is my view for Backbone
var RepoListView = Backbone.View.extend({
el: $('#wrapper'),
events: {
"click #more_repos" : "get_more_repos"
},
get_more_repos: function() {
ajax(get_repo_url, {offset:2}, this.render);
},
render: function(result) {
var template = Handlebars.compile($("#repos_hb").html());
$(this.el).find('#main_content').append(template({repos: result}));
return this;
}
});
And this is my ajax function that gets called from "get_more_repos" function
function ajax(url, data, post_ajax_function) {
$.ajax({
url: url,
data: data,
dataType: 'json',
success: function(result){
post_ajax_function(result);
}
});
}
However, it is not rendering, because "this.el" is undefined. Now after playing with it for awhile, it looks like the callback in "ajax(..)" function doesn't have access to "this.el". Any ideas how I can resolve this?