The [[Prototype]] JavaScript library provides a number of tools for manipulating the content of a view from the ClientSide. One such tool is the @Element@ object. The @Element@ object exposes a number of methods * toggle * hide * show * remove * getHeight h2. toggle The @Element.toggle()@ function will toggle the visibility of an element. This will make visible content disapear, or invisible content appear. h4. example
You can toggle more than one item at by passing more names to the function h4. examplefootoggle foo
h2. hide The @Element.hide()@ function sets the display style for the specified element ID(s) to 'none'. h4. examplefoobartoggle foo and bar
h2. show The @Element.show()@ function sets the display style for the specified element ID(s) to ''(empty string). h4. examplefoohide foo
show foo@Element.show()@ and @Element.hide()@ can both take multiple arguments, just like @Element.toggle()@ h2. remove The @Element.remove()@ function prunes the specified element and all of its children from the DOM tree for the current view of the page. i.e. if you refresh the page the element will return to its original position and display style. h4. example
h2. getHeight The @Element.getHeight()@ function returns the offsetHeight of the element specified. Generally this is the actual onscreen height of the displayed element. However, if this function is called from within a table, it might not return the value you expect. h4. example In a test page I created the following tablefooremove foo
| table contents |
| Element.getHeight('mytable'); = |
| table contents |
| Element.getHeight('mytable'); = |
| table contents |
| Element.getHeight('mytable'); = |
table contents
Element.getHeight('mytable'); = 40
table contents
Element.getHeight('mytable'); = 80
table contents
Element.getHeight('mytable'); = 120
It appears to me that each successive call to getHeight() returned the height of the table that had been rendered up to the time of the call. Note: any call to getHeight('mytable') after the page render had finished returned the final height of the table.
category: Howto, Stub