I'll throw in a Low Pro [1] version as well:

Event.addBehavior({
  'ul.bopCategories .bopCategoryDetails' : function() {
    this.hide();
  },
  'ul.bopCategories li h3:click' : function(e) {
    elm = e.element();
    elm.next('div.bopCategoryDetails').toggle();
    elm.toggleClassName('expanded');
  }
});

The first function will pre-hide the details. Remove it if it's not something you want to happen.

//jarkko

[1] http://jlaine.net/2007/8/3/from-rails-ajax-helpers-to-low-pro-part-i

On 3.10.2008, at 12.37, T.J. Crowder wrote:


Actually, let me revise that:

   function toggleContent(evt)
   {
       var elm;
       elm = evt.element();
       elm.next('div.bopCategoryDetails').toggle();
       elm.toggleClassName('expanded');
   }
   function initPage()
   {
       $$("ul.bopCategories li h3").each(function (elm) {
           elm.observe('click', toggleContent);
       });
   }
   Event.observe(document, 'dom:loaded', initPage);

The "dom:loaded" event is fired when the DOM is ready (before
window.onload, usually).
--
T.J. Crowder
tj / crowder software / com

--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi


Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to