On Apr 14, 11:15 pm, Tom Gregory <[EMAIL PROTECTED]> wrote: > 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); > } > });
Thanks. I considered this, but thought I might get hit by race conditions between the document.loaded check and document.observe() setting the event up. It's not possible for document.loaded to be set between the two? --M. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---