views:

11

answers:

1

Hello, is there a Rails 3 jQuery global loading event?

I'd like to display a LOADING banner anytime jQuery is AJAX loading... and remove it when it's done...

Ideas? Thanks

A: 

For global do this :

$("#loading").bind("ajaxSend", function(){
  $(this).show();
}).bind("ajaxComplete", function(){
  $(this).hide();
});

For individual do this :

$.ajax({type: "GET",
        beforeSend: function() { $.globalThrobberStart    },
        complete: function() { $.globalThrobberStop     }
        ...

See more here : http://docs.jquery.com/Ajax_Events

Trip