Hiding the first tab of accordion panel in JSF Pri

2019-02-09 01:09发布

By default the first tab of the primefaces accordion panel is shown open on page load. Is there a way that it can be closed on page load.

Thanks

6条回答
在下西门庆
2楼-- · 2019-02-09 01:21

It works if you set activeIndex to blank (Primefaces 3.4.1).

<p:accordionPanel activeIndex="">
查看更多
我只想做你的唯一
3楼-- · 2019-02-09 01:22

You can do it with the PF function, as the code below:

PF('accordionWidgetVarName').unselect(0);
查看更多
smile是对你的礼貌
4楼-- · 2019-02-09 01:23

One approach is to define a widgetVar:

<p:accordionPanel widgetVar="accordion">
    ...
</p:accordionPanel>

And then:

<body onload="PF('accordion').unselect(0)">

or for older PF versions:

<body onload="accordion.unselect(0)">
查看更多
混吃等死
5楼-- · 2019-02-09 01:23

None of the posted answered worked for me in PrimeFaces 3.5.x. using multiple mode, but this:

<p:accordionPanel multiple="true" activeIndex="null" ... >
查看更多
Root(大扎)
6楼-- · 2019-02-09 01:24

Answering for PrimeFaces 6.0 users:

You can set the widgetVar property and then call PF('widgetVarValue').unselect(0); as Fred Policarpo mentioned; however, I was not able to get this to work upon accordion load, and I tried various things like using a div's onload event, using a remoteCommand with autoRun enabled, and even using custom jQuery. None of these worked for the load event, only when I ran that PF unselect call in the console.

In PrimeFaces 6.0, you can use the activeIndex attribute and set it to multiple values, e.g. "1,3,5", to close all of the tabs but open the 2nd, 4th, and 6th tabs (base 0 indexing).

查看更多
爱情/是我丢掉的垃圾
7楼-- · 2019-02-09 01:29

You can just do

<p:accordionPanel activeIndex="-1">
查看更多
登录 后发表回答