The reason for this is because if the element.style.display and element.style.visibility are not always visible via JS calls. This means you can not probe elements that use class names and inline styles for their default state. After JS is used to alter the state of display, it then becomes a readable attribute (I don't know why).
Toggle attempts to avoid this issue by not probing the object at all. Toggle assumes that the element will be visible by default and sets style.display = "none" as the first action. It also keeps an array of the state of all objects toggle has touched. Since it assumes items are visible the first time, the stored state is corrupt. Therefore, to use toggle the element must be visible the first time it is called. I know of no work around. Toggle could be changed to attempt a style look up, however then toggle's behavior will be inconsistent between JS touched and non-touched JS elements. -Andrew Martinez -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Dirk Eschler Sent: Thursday, May 25, 2006 1:38 PM To: [email protected] Subject: [Rails-spinoffs] Hide content before page load Hi, i've been experimentating with dynamicCSS.js [1] to hide content only if JavaScript is enabled. It works pretty well and fires before onload to avoid the flash of visible content. Now i'm wondering if there is a Prototype way of doing this. [1] http://www.bobbyvandersluis.com/articles/dynamicCSS.php My main problem is that Prototype functions like Element.toggle() do not work on elements that were used together with the dynamically created styles. Best Regards, Dirk Eschler -- Dirk Eschler <mailto:[EMAIL PROTECTED]> http://www.krusader.org _______________________________________________ Rails-spinoffs mailing list [email protected] http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs _______________________________________________ Rails-spinoffs mailing list [email protected] http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
