I am using backbone to create all my views. Some of my views are quite resource intensive and take a while to load into the template. So when clicking on some line, I want to first show a loading overlay and remove it when the view is rendered.
$('.class').live('click', function(){
$("#loading").fadeIn();
// this changes the url and then the view is called.
});
But the problem is that the loading but only comes up once the view is rendered. Why is this? what is the event pattern here? Like when you click on the link does it load the url first then only the things inside the click callback, cause it seems so. Even with this it does the same:
$('.content a').click(function () {
var f = $(this);
$("#loading").show();
Backbone.history.navigate(f.attr("href"), true);
return false;
});