Accordion / multiple instances - only one opened
i am using ui accordion.
i have multiple instances of the same accordion on one page.
because it is the same accordion duplicated, the links inside it have the same href value, so every accordion is opened... but I need only one OPENED accordion, the one were the click came from.
Is this possible? Can someone help me with this?
thank u.
$('#nav ul li').accordion({
active: 'a.current',
header: '.head',
navigation: true,
event: 'click',
//fillSpace: true,
animated: 'easeslide',
collapsible: true,
autoHeight: false
});
$("#nav ul li").each(function () {
var li = $(this);
var a = li[0].firstChild;
if (a.href == location.href) {
$(a).addC开发者_JS百科lass("current");
}
});
You need to implement a (this) into your jquery code, can you post your current code so we can see
The only thing i can think of is this:
$('#nav ul li', this).accordion({
active: 'a.current',
header: '.head',
navigation: true,
event: 'click',
//fillSpace: true,
animated: 'easeslide',
collapsible: true,
autoHeight: false
});
Maybe try something like this:
$(".ac-menu").accordion({
"header": "a.menuitem"
})
.bind("accordionchangestart", function(e, data)
{
data.newHeader.next().andSelf().addClass("current");
data.oldHeader.next().andSelf().removeClass("current");
})
.find("a.menuitem:first").addClass("current")
.next().addClass("current");
精彩评论