Thanks for that one, too. Less is more!
Walter
On Apr 24, 2007, at 8:46 PM, David Dashifen Kees wrote:
>
> This would be another option in addition to Michael's:
>
> Event.observe(window, "load", function() {
> $$("#test h3").each(function(element) {
> element.addClassName("fakelink");
> element.next("div").hide();
> element.observe("click", function() { this.next("div").toggle();
> }.bind(element));
> });
> });
>
> Walter Lee Davis wrote:
>> I have a little script to do expand-o headers within a single div:
>>
>> Event.observe(window,'load',function(){
>> var headers = $('test').getElementsBySelector('h3');
>> for (var i = headers.length - 1; i >= 0; i--){
>> headers[i].addClassName('fakelink');
>> headers[i].next('div').hide();
>> headers[i].observe('click',function(e){
>> this.next('div').toggle();
>> }.bind(headers[i]));
>> };
>> });
>>
>> I count at least three too many headers[i] in the above, and I'm
>> wondering if someone could take a moment to show me the cool-kids way
>> to do the same thing. I am guessing it is probably some one-word magic
>> like 'each' or something like that...
>>
>> Thanks,
>>
>> Walter
>>
>>
>>>
>>
>>
>
> >
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---