I'm trying to use a primefaces commandbutton as toggle button. My idea was to add a css class with the desired style, in this way:
<p:commandButton id="mybutton" onclick="toggleButton();"/>
javascript:
function toggleButton() {
$(this).toggleClass("myCustomClass");
return true;
}
css:
.myCustomClass{
background-color: red;
}
For some reasons, this doesn't work. My supposition is that PF does some magic with button's style, and my class is added and right away removed. Some hint?