What he said.
This is what I was getting at, although I haven't been up on the
Prototype changes enough to have known that newer versions extend the
document object with the useful document.loaded attribute.
More to your situation, just plug jdalton's code inside your
onSuccess declaration:
var ajax = new Ajax.Request(url, {
onSuccess: function(res) {
// jdalton's code:
var callback = function() {
// Do stuff; can use res as an in-scope variable.
// Be careful if this callback could be called more than
once before DOM is loaded
};
document.loaded ? callback() : document.observe('dom:loaded',
callback);
}
});
TAG
On Apr 14, 2008, at 4:03 PM, jdalton wrote:
>
>
>
> var callback = function(){
> //do stuff
> };
>
> if(document.loaded) callback();
> else document.observe('dom:loaded', callback);
>
> - JDD
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---