Prototype equivalent to jQuery document.ready?

1 view
Skip to first unread message

Walter Lee Davis

unread,
Apr 25, 2007, 10:12:04 AM4/25/07
to rubyonrail...@googlegroups.com
As I understand it, jQuery document.ready signals way before
Event.observe(window,'load'...), since it knows somehow that the DOM is
ready, even if all the graphics haven't loaded yet.

Is there a similar event I could hook on to in Event.observe that would
get me the benefit of quickly hiding a big page full of tab content
before it has a chance to flash on screen?

Thanks in advance,

Walter

Peter De Berdt

unread,
Apr 25, 2007, 10:24:08 AM4/25/07
to rubyonrail...@googlegroups.com
lowpro.js (http://www.danwebb.net/2006/9/3/low-pro-unobtrusive-scripting-for-prototype) has this function and it's in the latest beta of prototype too.


Best regards


Peter De Berdt


Tom Gregory

unread,
Apr 25, 2007, 2:07:38 PM4/25/07
to rubyonrail...@googlegroups.com
In some browsers it observes the DOMContentLoaded event. In others
(IE) there are different workarounds.

The following links should get you started:
http://dean.edwards.name/weblog/2006/06/again/
http://ajaxian.com/archives/domcontentloadednext
http://www.google.com/search?q=domcontentloaded


TAG

RobG

unread,
Apr 26, 2007, 1:22:37 AM4/26/07
to Ruby on Rails: Spinoffs

This has been discussed here before, search for a thread with subject:

" Help! Slow Loading Issue"
<URL:
http://groups.google.com.au/group/rubyonrails-spinoffs/browse_frm/thread/d19259e3a3e39a6b/1c1bc52491612102?lnk=gst&q=Slow+Loading+Issue&rnum=1#1c1bc52491612102
>

The simplest solution is to setup an initialisation function (say
called "init()") that you would have called onload and call it from a
script just before your closing body tag, e.g.:

<body>

<!-- lots of stuff ... -->

<script>init && init()</script>
</body>


And save yourself a whole slab of browser-sniffing code that will fail
at least some of the time.


--
Rob

Tom Gregory

unread,
Apr 26, 2007, 1:39:57 AM4/26/07
to rubyonrail...@googlegroups.com
Rob has mentioned this the last several time the discussion has come
up, and yet I still don't remember it. I should--it's certainly easy
and effective.

At times I wonder whether my brain is hard-wired to select the most
difficult solution available. Maybe one of these days I'll wise up. =)

Thanks Rob!


TAG

Reply all
Reply to author
Forward
0 new messages