Ajax.Responders.register({
onCreate:function() {
if($('busy') && Ajax.activeRequestCount > 0) { // does the busy
element exist, and have we requested ajax?
$('busy').style.paddingTop =
getPageScroll()[1]+80+'px'; // set
the indicator to somewhere roughtly centered top-down
$('busy').style.display = 'block'; // and show
the element
}
},
onComplete:function() { // when we're finished being busy, shut it
off
if($('busy')) { // does the busy element exist?
$('busy').style.display = 'none'; // turn the element
off
}
}
});
Note: this code requires you to have a container element on every page
with the id "busy", I chose to use an animated gif 80 x 80 pixels that
is a spinning loading circle.
Very *important* caveat: You have to be very careful with this,
because this can cause problems with some elements, like javascript
tooltip rollovers that load their content via ajax, as the system will
constantly switch on and off the activeRequestCount between 1, 2, and
0. I had another if statement inside the first one to cancel this
action. I can paste more code if necessary.
On Jun 13, 2:36 pm, Terry Riegel <[EMAIL PROTECTED]> wrote:
> I would be interested in the full function.
>
> Terry Riegel
>
> On Jun 13, 2007, at 2:32 PM, conspireagainst wrote:
>
>
>
> > Is there any possible way (I'm using prototype framework) to glean
> > what the name of the container element to be updated (using
> > Ajax.Updater) is?
>
> > I have appended at the bottom of prototype.js a function that shows a
> > loading dialog when any AJAX interaction takes place (I use this all
> > the time, it's AMAZING, feel free to use it, and if you want the rest
> > just reply and I'll paste all the code), but I need to cancel it for
> > one particular element and cannot figure out a way without knowing the
> > element name.
>
> > Here's the code:
>
> > Ajax.Responders.register({
> > onCreate:function() {
> > if($('busy') && Ajax.activeRequestCount > 0) {
> > // show the loading dialog
> > }
> > }
> > });
>
> > ..... (more code)
>
> > I would love to do something like alert(Ajax.Updater.container); but
> > that does not work, does anyone know how to do this?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---