Jörn Zaefferer schrieb:
> Hi jQueryians,
>
> just improved and commited the jQuery accordion plugin, or rather "Accordion 
> widget". Whatever you like to call it, it's quite neat and very flexible.
>   
That is true once more!

Please checkout the updated demo: 
http://joern.jquery.com/accordion/accordion.html

It's now even more flexible: handling nested div structures (third 
example) is possible as long as the header is marked somehow.

And what is really cool: I managed to hijack jQuery's event system: The 
accordion now triggers a "change" event everytime the content changes, 
so clients can simply bind to that callback if they are interested. The 
code from the demo:

$('#list2').Accordion({
        active: 'dt.selected'
}).change(function(event, newHeader, oldHeader, newContent, oldContent) {
        simpleLog(oldHeader.text() + ' hidden');
        simpleLog(newHeader.text() + ' shown');
});

And even more intersting, it's now possible to trigger this change 
programmatically, just like tab's triggerTab. From the demo:

$('#switch select').change(function() {
        $('#list1, #list2').activate( this.selectedIndex-1 );
});

The implementation for activate is this:

$.fn.activate = function(index) {
        return this.trigger('activate', [index || 0]);
};

The Accordion widget binds itself to the activate event and can easily 
access all necessary settings that way. That way I don't have to pass 
around lots of variables, or in the worst case, bind them directly to 
DOM elements.

@Klaus: I think it would be pretty easy to modify the tab's plugin to 
use the same event. As you may notice, my usage for activate has some 
small differences. I prefer a zero-based index as most programmers are 
used to that anyway. I hope you can reuse some of the ideas from the 
accordion, because I got a lot of inspiration from your tabs :-)

@Yehuda: Could you please update your build.xml? I added both tooltip 
and accordion, would be nice to see the docs on visualjquery.com

-- 
Jörn Zaefferer

http://bassistance.de


_______________________________________________
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/

Reply via email to