Onchange in <p: selectCheckboxMenu doesn't start when all are selected
This is my code:
<p:selectCheckboxMenu id="myselect" onchange="fixLable(this)" value="#{mybean.value}" >
<f:selectItems value="#{mybean.values}"/>
</p:selectCheckboxMenu>
I wrote a java script function named fixLable (this) that will be called when one of these checkboxes is selected. it is called every time you click on the checkboxes except the Select All checkbox. What for? is there a separate attribute for "select all"?
i read in: p: selectCheckboxMenu 'Select all' no ajax listener is listening that you can use the toggleSelect ajax event and then execute your code with onajaxstart or onsuccess etc ... but i dont want to use ajax because it is slower than just calling javascript on an event.
any suggestions? I posts that you can add an eventlistener to the Select All checkbox.
source to share
This may be a little misleading, but you can actually use an element <p:ajax>
to call a javascript function without sending any ajax requests to the server. <p:ajax>
has an attribute onstart
that any javascript code can execute. If yours return false
is javascript from this block, you will disallow processing the request, so nothing is sent to the server.
<p:ajax event="toggleSelect" onstart="fixLable(this); return false" />
source to share