Hi, I am loading prototype dynamically using the following js: var scr=document.createElement(''script''); scr.setAttribute("type","text/javascript"); scr.setAttribute("src","./static/js/lib/prototype.js"); document.getElementsByTagName("head") [0].appendChild(scr); on IE6 I get the following error: ''null'' is null or not an object The error occurs on the following lines: document.write("<script id=__onDOMContentLoaded defer src=//:><\/script>"); $("__onDOMContentLoaded").onreadystatechange function() { if (this.readyState == "complete") { this.onreadystatechange = null; fireContentLoadedEvent(); } }; Is there a standard work around for this ? Thanks in advance http://groups.google.com/group/rubyonrails-spinoffs/browse_thread/thread/df6f0fc4187deee0/fa578791886b08dc?lnk=gst&q=DOMContentLoaded+error#fa578791886b08dc --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On 12/3/07, geevee <gautam.verma-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Hi, > > I am loading prototype dynamically using the following js: >... > The error occurs on the following lines: > > document.write("<script id=__onDOMContentLoaded defer > src=//:><\/script>"); > ... > > Is there a standard work around for this ? > ...I submitted this patch for consideration: http://dev.rubyonrails.org/ticket/10355 If it meets your needs, consider putting in a request for the patch to be included in prototype 1.6.0. It simply disables the dom:loaded functionality for IE. I don''t believe there is a way to test if the document is already loaded in other browsers (IE uses readyState) so there is no way to preserve dom:loaded functionality when prototype is loaded dynamically (not to mention it doesn''t really make sense). In other words, the patch will prevent errors, but $(id).observe(''dom:loaded'', callback) will never fire. - Ken Snyder --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
I wanted to have a public _loaded flag for a long time ( simple getter like document.isLoaded() might be even nicer ) Wouldn''t this as well solve a dynamic loading problem? http://dev.rubyonrails.org/attachment/ticket/10355/document._loaded.diff --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Dec 3, 2007 10:37 PM, kangax <kangax-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I wanted to have a public _loaded flag for a long time ( simple getter > like document.isLoaded() might be even nicer ) > Wouldn''t this as well solve a dynamic loading problem? > > http://dev.rubyonrails.org/attachment/ticket/10355/document._loaded.diffYour use of document._fired can be generally helpful, but dynamically loading prototype after the page loads (e.g. when the user clicks something) will cause dom:loaded to never fire. Prototype fires all the registered events based on a callback from a DOMContentLoaded listener. If DOMContentLoaded listeners are attached after the page is loaded, they never fire. Also note that there might be a case for tweaking Event.observe() to immediately fire dom:loaded listeners if document._fired == true. I remember that coming up before when a script block is toward the bottom of a document, but I couldn''t reproduce it when I tried. To be simple, you might event want to use document.readyState ''complete'' instead of document._fired = true, but then again that may have side effects. - Ken Snyder --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---