Arian
Arian

Reputation: 3241

Close all tabs of p:accordionPanel on page load

Accordionpanel tabs are not closed when moving the second time to the page, even with activeIndex="" the tabs are closed only the first time moving to the page. I'm using Primefaces 3.5 and MyFaces 2.1.5.

<p:accordionPanel id="accordionServers" style="width:400px" multiple="true" activeIndex="" cache="false" dynamic="true">
<p:tab title="Tab1"></p:tab>
<p:tab title="Tab2"></p:tab>
</p:accordionPanel>

What is the simplest workaround?

Upvotes: 0

Views: 7758

Answers (4)

user3126748
user3126748

Reputation: 51

In my scenario setting activeIndex="-1" or activeIndex="null" or activeIndex="-" or activeIndex="" did not work.

I returned -1 from manager bean and it worked. Getter always returns -1 and setter does nothing.

activeIndex="#{managerBean.activeTabIndices}"

p.s. I needed all tabs to be always closed initially.

Upvotes: 2

Fred Policarpo
Fred Policarpo

Reputation: 111

You can close all tab of an accordion by JavaScript, using JQuery, as the code below.

 for (var i = 0; i< $(".ui-accordion-header").size(); i++) {
        PF('accordionWidgetVarName').unselect(i);
 }

Upvotes: 0

Jakjoud
Jakjoud

Reputation: 41

Try this

activeIndex="null"

It worked just fine !!

Upvotes: 4

fperez
fperez

Reputation: 492

activeIndex="-", in Primefaces 3.4, when multiple="true"

<p:accordionPanel 
    id="accordionServers" 
    style="width:400px" 
    multiple="true" 
    activeIndex="-" 
    cache="false" 
    dynamic="true">
    <p:tab title="Tab1" />
    <p:tab title="Tab2" />
</p:accordionPanel>

Upvotes: 2

Related Questions