Use Drupal JS Libraries : Your own collapsible fieldset
Last modified: October 15, 2008 - 20:06
The best-practice way to include javascript is to do it the way that Drupal already does. As well as being correct and concise, it avoids double-loading already available routines.
To add the Drupal 'collapsible' effect anywhere in your own page or theme, the following code should work. This can be pasted directly into the (HTML) of any node but does require PHP input format to be enabled.
<?php
drupal_add_js('misc/collapse.js');
?>
<fieldset class=" collapsible collapsed">
<legend>More Info</legend>
<div class="fieldset-wrapper">
<h3>Content goes here</h3>
<p>
Lots of hidden text.
Lots of hidden text.
Lots of hidden text.
Lots of hidden text.
Lots of hidden text.
</p>
</div>
</fieldset>Sorry, a demo won't work on Drupal Docs pages, but I'm sure you will get the idea :-}
