> Does this empty-string method work across all major browsers?
I believe so, but I'm not certain; as soon as I have some time I'll do
some testing to confirm this.

> The recommended way, as documented, is to use a CSS class with a
> display: none and override show/hideElement and isVisible to
> appropriate invocations of remove/add/hasElementClass
I am aware of this, and agree 100%.  As documented on QuirksMode
(http://www.quirksmode.org/dom/classchange.html), adding/removing
classes is clearly faster than adding/removing styles directly.
However, there are plenty of circumstances where this ideal solution
isn't practical.

In my specific case, I can add my own stylesheet, but my code will be
used on pages with other stylsheets that I can't control.  If I define
a "nodisplay" class as ".nodisplay{display:none}", and any of those
stylesheets contains a display rule with higher specificity (ie.
"#someSpan.article{display:block"), that rule will trump mine, and
adding the "nodisplay" class to that element won't do anything.
Furthermore, I'm sure many corporate developers operate in
environments where they don't even have access to their pages' css,
and therefore a "nodisplay" class is not an option for them either.

For users like us, a better hideElement/showElement function would
certainly be helpful.

> Except that for elements which originally had display:none,
> showElement would keep them hidden.
I hadn't considered this, and it certainly provides a reason for
showDisplay to use "block" instead of an empty string.  However, this
only applies in cases where content is hidden by CSS, not by JS, and
if you're able to hide your content via CSS then you're able to use
the "nodisplay" class solution instead.  For situations where CSS-
related solution isn't an option (which I think everyone would agree
is the only time anyone should ever be using these functions), having
showElement set the display style to "" makes a lot of sense to me.

I guess what it comes down to is that you can either have show/
hideElement functions that are immune to CSS, but only work for block
elements, or you can have functions that can be messed up by CSS that
is made specifically to hide content, but which work for tables,
spans, etc.  Neither is ideal, but for the limited amount of "proper"
uses of this function, I would argue that the latter is more suited
(assuming it's cross-browser compatible).

Jeremy

On Aug 30, 8:49 am, "Leo Soto M." <[EMAIL PROTECTED]> wrote:
> On 8/29/07, machineghost <[EMAIL PROTECTED]> wrote:
>
>
>
> > The Mochikit Style function "showElement" works as follows:
> > <code>this.showElement = m.partial(this.setDisplayForElement,
> > 'block');</code>
>
> > In other words, it sets the display style of the element to "block".
>
> [...]
>
> > However, there is another way.
>
> > If this function were instead:
> > <code>this.showElement = m.partial(this.setDisplayForElement, '');</
> > code>
> > (in other words, if it set the element's display style to an empty
> > string)
>
> > it would set the element's display style to nothing, which would
> > effectively set it back to whatever it was originally ("block" for a
> > block-level element, "inline" for an inline one, etc.).
>
> Except that for elements which originally had display:none,
> showElement would keep them hidden.
>
> As documented, the reliable way to show/hide things is using a CSS class for 
> it.
>
> --
> Leo Soto M.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/mochikit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to