Google Groups Home
Help | Sign in
Message from discussion Anyone Else Interested in a New Synthesized "onReady" Event (ala JQuery)?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Per Cederberg  
View profile
 More options May 7, 1:51 am
From: "Per Cederberg" <cederb...@gmail.com>
Date: Wed, 7 May 2008 07:51:01 +0200
Local: Wed, May 7 2008 1:51 am
Subject: Re: [mochikit] Re: Anyone Else Interested in a New Synthesized "onReady" Event (ala JQuery)?
I liked the "ondomready" name and structure. Looking at MSDN, they
provide the following solution instead of writing new script tags into
the document (not tested, just pasted):

document.onreadystatechange=fnStartInit;
function fnStartInit()
{
   if (document.readyState=="complete")
   {
      // Finish initialization.
   }

}

Otherwise I like the proposed solutions and vote for inclusion to
MochiKit.Signal. Never know when it might be handy.

Cheers,

/Per

On Wed, May 7, 2008 at 6:21 AM, Felipe Alcacibar B <falcaci...@gmail.com> wrote:

>  oops, some mistake in the webkit part, sorry

>  [code]

> if (/WebKit/i.test(navigator.userAgent)) {
>   var __domready__timer__ = setInterval(function() {
>     if (/loaded|complete/.test(document.readyState)) signal(window,
>  'ondomready');
>     clearInterval(__domready__timer__);
>   }, 10);
>  [/code]

>  On 7 mayo, 00:12, Felipe Alcacibar B <falcaci...@gmail.com> wrote:
>  > MochiKit is wonderful, as you wrote ir, but is the base, you can made
>  > too much things, but you may need read or investigate some more time
>  > like jQuery.

>  > I prefer call it domready, because it is when dom nodes are loaded, i
>  > use this code to implement domready, and i not have any problem.

>  > [code]
>  > var __domready__ = false;
>  > if (document.addEventListener)
>  >         document.addEventListener("DOMContentLoaded", function() { if(!
>  > __domready__) { __domready__ = true; window.signal(window,
>  > 'ondomready') }; }, false);

>  > /*@cc_on @*/
>  > /*@if (@_win32)
>  >     document.write("<script id=__ie_onload defer
>  > src=javascript:void(0)><\/script>");
>  >     document.getElementById("__ie_onload").onreadystatechange =
>  > function() {
>  >         if (this.readyState == "complete") {
>  >                 signal(window, 'ondomready');
>  >         }
>  >     };
>  > /*@end @*/

>  > if (/WebKit/i.test(navigator.userAgent)) {
>  >   var __domready__timer__ = setInterval(function() {
>  >     if (/loaded|complete/.test(document.readyState)) signal(window,
>  > 'ondomready');
>  >     clearInterval(ctimer);
>  >   }, 10);}

>  > [/code]

>  > and when i need to call them i use

>  > [code]
>  > connect(window, 'ondomready', function () {
>  >       alert('now i know kung fu');});

>  > [/code]

>  > Felipe Alcacibar Buccioni
>  > Developer of systems and solutions

>  > On 6 mayo, 17:47, machineghost <machinegh...@gmail.com> wrote:

>  > > Hey All,

>  > > In trying to explain why he liked jQuery, a co-worker of mine clued me
>  > > in to a fairly cool method in that library: "ready(someFunc);".  For
>  > > those who aren't familiar with jQuery, you can think of this method as
>  > > something like:
>  > > partial(connect, document, "DOMContentLoaded")

>  > > In other word, it connects the provided function to the
>  > > "DOMContentLoaded" document event.  Now, the specific jQuery syntax I
>  > > could care less about (with partial I can already make any "connect"
>  > > variant I want), but what is really cool about the function is that it
>  > > makes it really easy to use the "DOMContentLoaded" event.  And why is
>  > > that cool?

>  > > 1) The "DOMContentLoaded" event fires sooner (and if you have a heavy
>  > > page, MUCH sooner) than the "onLoad" event (although you can't do
>  > > stuff that depends on the rendered DOM, like getElementDimensions,
>  > > until "onLoad" goes off).  As a result, you can get significant
>  > > performance improvements just by changing (most of) your "onLoad" code
>  > > to be "onDOMContentLoaded" code.

>  > > 2) Internet Explorer doesn't support "DOMContentLoaded" :-(  Luckily
>  > > however, this guy:http://javascript.nwbox.com/IEContentLoaded/
>  > > figured out a hack to emulate the event in IE.  When you call
>  > > "ready(someFunc)", behind the scenes JQuery handles figuring out
>  > > whether to use the hack or the real event.

>  > > Now, I don't have any desire to switch to jQuery; it has the same
>  > > basic stuff as Mochikit, but none of the wonderful advanced stuff like
>  > > partial, keys, etc.  I would however like to have access to this
>  > > "fake" event.  Am I alone in this, or would others on this list like
>  > > to see a synthesized Mochikit "DOMContentLoaded" event (similar to the
>  > > existing synthesized "onmouseenter" and "onmouseleave" events)?

>  > > If there is interest in this event I'll be happy to help write a
>  > > proper Mochikit patch, but if not I'll just steal (quick and dirty
>  > > style) the jQuery event for my own purposes.


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google