Solution: Use p:selectBooleanButton
Problem: How to show p:selectBooleanButton as a normal button for two states? This code
Code: Select all
<p:selectBooleanButton value="true" onLabel="Show advanced search" offLabel="Hide advanced search"
onchange="$(this).parent().removeClass('ui-state-hover ui-state-active'); myWidget.toggle()"/>
This code works
Code: Select all
<p:selectBooleanButton value="true" onLabel="Show advanced search" offLabel="Hide advanced search"
onchange="$(this).parent().removeClass('ui-state-hover'); myWidget.toggle()"/>
Any suggestions? I think PrimeFaces should save current state (Yes / No) in JS DOM object (e.g. via jQuery's data(...) on checkbox). Instead this CSS classes are checked. It's valid for the most PrimeFaces components. Do we need an issue, Cagatay? Workarounds are welcome. Using p:commandButton with type="button" is not desired because it needs JavaScript logic to change button text on click.