in Hacking

Prototype automatic Spinner

I found the following code on the internet. By using this code, a spinner is showed automaticly if an Ajax request is running. Very nice!

// registreer een algemene spinner
Ajax.Responders.register({
  onCreate: function() {
  if (Ajax.activeRequestCount > 0)
    Element.show('spinner');
  },
  onComplete: function() {
  if (Ajax.activeRequestCount == 0)
    Element.hide('spinner');
  }
});

Didn't know prototype had this global register method. I should take a better look at the API!