On Nov 17, 2005, at 10:02 PM, Ryan Wilcox wrote:
I really (really!) enjoy using MochiKit. Even though I don't have much
experiance using JavaScript/DOM, I'm up, running, and building useful
apps. A testament to the design and documentation of MochiKit, if
nothing else. :)
Glad to hear it!
Now for my question:
I see that I can make an visible/invisible with
showElement()/hideElement(). However, what if I want to toggle the
visible state of an element?
This is the best way to do it, to my knowledge:
<style type="text/css">
.invisible { display: none; }
</style>
<script type="text/javascript">
var toggleVisibility = partial(toggleElementClass, "invisible");
var isVisible = function (elem) { return !hasElementClass(elem,
"invisible"); };
</script>
I can't really make it part of MochiKit because you can't really
define CSS rules dynamically cross-browser. showElement and
hideElement are just hacky little functions that are useful for block
elements. Perhaps I should add an "element visibility" section to
the DOM docs and say that showElement/hideElement have caveats.
-bob