BezrA
BezrA

Reputation: 223

How to Expand/Collapse Primefaces fieldset using jquery?

I'm using primefaces 3.5 and I have a p:fieldset and a p:commandbutton, I'm able to toggle the fieldset using the button using it's client side api method

oncomplete="detailsFieldset.toggle()"

but I'd like to only Expand the fieldset if it's collapsed not the opposite.

Upvotes: 2

Views: 4188

Answers (2)

DaleC
DaleC

Reputation: 1

Modified the above solution by Daniel

oncomplete="if($(detailsFieldset.toggleStateHolder).attr('value') === 'true'){detailsFieldset.toggle();}"

to

oncomplete="if($(detailsFieldset.stateHolder).attr('value') === 'true'){detailsFieldset.toggle();}"

for it to work for me.

Upvotes: 0

Daniel
Daniel

Reputation: 37051

You can use this:

oncomplete="if($(detailsFieldset.toggleStateHolder).attr('value') === 'true'){detailsFieldset.toggle();}"

toggleStateHolder holds the state of the collapsed mode... so when its value is true it means that the p:fieldset (or any other pf collapsible element) is collapsed.

Upvotes: 1

Related Questions