I want to pass an extra variable (the userid) with before rendering my backbone view. I am getting the the extra variable with a ajax request but because is asynchronous I think my page is being rendered before I get the variable. For simplicity lets say I have this in my backbone view :
PostsApp.Views.Post = Backbone.View.extend({
    template: _.template($('#post-template').html()),
    render: function(){
        var newObject = this.model.toJSON();
        $.ajax({
            url:"/user",
            success:function(result){
                newObject.twittername = result.name; ;
            }
        });
        this.$el.html(this.template(newObject));
    }
});
I guess I can put this.$el.html(this.template(newObject)); in the callback but than 'this'refers to something else.. Can anyone think of a work around for this?
Or is it completely very bad to send such a request in the render function..
 
     
    