[Prototype-core] Re: simulated DOMContentReady event
IMHO, contentloaded should be fired once, when the DOM of the initial page is completely loaded and parsed by the browser. Loading in stuff via Ajax shouldn't trigger this event. YMMV, but you can add a global ajax responder and fire a fragmentloaded (or so) custom event, and oberve that, or just use text/javascript returns (note that this would well be something that we consider for inclusion in the library!). I think making contentloaded too magic breaks POLS. best, ghomas Am 31.08.2007 um 17:25 schrieb Jeff Watkins: On Aug 31, 2007, at 12:34 AM, Andrew Dupont wrote: Jeff, my suggestion is to write your own Event.onReady function (or something like it) that wraps around the 1.6 event code. Yeah, that's kind of what I figured. But since it's got to be a pretty common situation, I thought it might deserve a solution in the library. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: simulated DOMContentReady event
On 9/1/07, Thomas Fuchs [EMAIL PROTECTED] wrote: IMHO, contentloaded should be fired once, when the DOM of the initial page is completely loaded and parsed by the browser. ... I think making contentloaded too magic breaks POLS. Actually it works the other way around for me. My mind maps the I've just loaded this fragment via ajax to I've just finished loading this dom, but that's me, and I understand this is subjective. Anyway, the custom event solution seems tidy enough. What do the w3c specs say on xmlhttprequests and contentloaded, if anything? -Nicolas --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: simulated DOMContentReady event
On Sep 1, 5:18 pm, Nicolás Sanguinetti [EMAIL PROTECTED] wrote: Anyway, the custom event solution seems tidy enough. What do the w3c specs say on xmlhttprequests and contentloaded, if anything? They don't. Despite its name, the DOMContentLoaded event is not part of any standard. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: simulated DOMContentReady event
On 8/31/07, Jeff Watkins [EMAIL PROTECTED] wrote: For example, imagine you have a widget which would like to perform its initialisation only after the DOM is ready. It registers a listener for contentready on the document. All is fine. Now let's add Ajax to the mix. The widget is instantiated via content injected via Ajax. The registration for contentready will never be called. Let me see if I'm getting this correctly. You are saying that you need to inject content in the DOM received by XHR ... while the current page is still being loaded? That is strange to me. The previous implementation of Event (never released) had something in the lines of LowPro: Event.onReady(handler). You could register to listen for DOMContentLoaded like this, and the benefit was that it would immediately fire if you were adding handlers after the DOM has been fully loaded. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: simulated DOMContentReady event
On Aug 31, 2:12 am, Mislav Marohnić [EMAIL PROTECTED] wrote: On 8/31/07, Jeff Watkins [EMAIL PROTECTED] wrote: Let me see if I'm getting this correctly. You are saying that you need to inject content in the DOM received by XHR ... while the current page is still being loaded? That is strange to me. No. He's talking about what you hint at in your second paragraph. Imagine you've got a page with some inline code that assigns stuff to DOMContentLoaded. Now imagine it's a fragment, not a full page, and you're loading it via Ajax. Jeff, my suggestion is to write your own Event.onReady function (or something like it) that wraps around the 1.6 event code. Cheers, Andrew --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: simulated DOMContentReady event
Andrew Dupont wrote: ... Imagine you've got a page with some inline code that assigns stuff to DOMContentLoaded. Now imagine it's a fragment, not a full page, and you're loading it via Ajax. Jeff, my suggestion is to write your own Event.onReady function (or something like it) that wraps around the 1.6 event code. ... If I remember correctly, this situation happens anytime a script fragment just before /body/html tries to attach a handler onDOMContentLoaded: the content registers as loaded before the script fragment can finish executing. I found it essential that the wrapper account for situations where events are attached to onDOMContentLoaded after onDOMContentLoaded has fired. - Ken Snyder --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---
[Prototype-core] Re: simulated DOMContentReady event
Dan Webb's LowPro[1] solves this kind of issue by registering a global Ajax.Responder that evaluates DOMContentReady behaviors onComplete. Thinking along similar lines, you could wrap Event.observe so that observers set for contentloaded are also stored into a queue that gets processed after every Ajax.onComplete. I'm just spilling my thoughts here, but I think it would work well for most cases. How do you feel about this? (and, does it have any major drawbacks I'm not seeing?) Best, -Nicolas [1]: http://svn.danwebb.net/external/lowpro/trunk/ On 8/30/07, Jeff Watkins [EMAIL PROTECTED] wrote: Having prototype simulate the DOMContentReady event for those browsers that don't support it is wonderful, however, what is the plan for calling late registrants? For example, imagine you have a widget which would like to perform its initialisation only after the DOM is ready. It registers a listener for contentready on the document. All is fine. Now let's add Ajax to the mix. The widget is instantiated via content injected via Ajax. The registration for contentready will never be called. The solution I've been using is based on someone's Event.onDOMReady code: if the event has already been fired, I call the listener after a brief delay (to maintain the implicit contract call this function later) via window.setTimeout(fn, 0). Am I missing something critical about the implementation of the synthesised contentready event? On the other hand, maybe contentready isn't the right answer here, because when browsers _really_ support DOMContentReady, it won't do what I want anyway. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Prototype: Core group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~--~~~~--~~--~--~---