I am new to jquery. My project invovles primefaces 4.0, jsf 2.1 (xhtml).
I have a select all boolean checkbox, and a selectmanycheckbox which is filled using a list retreived from the server side.
<p:tab title="Service Status" >
<p:selectBooleanCheckbox itemLabel="Select All"
value="#{myBean.selectAllStatus}"
id="selectAllStatus" style="margin-left:4px;" onchange="selectAllStatus(this);" >
</p:selectBooleanCheckbox>
<p:selectManyCheckbox
value="#{myBean.serviceStatusFilterList}"
layout="pageDirection" id="empListSub">
<f:param name="tabValue" value="1" />
<f:selectItems value="#{serviceCalendarViewBean.serviceStatusList}" var="status"
itemLabel="#{status.title}" itemValue="#{status.id}"/>
</p:selectManyCheckbox>
</p:tab>
</p:accordion>
The Javascript called when the 'select all' checkbox is clicked is
function selectAllStatus(element)
{
var selectAll = element.checked;
$( 'input[id^="'accord:empListSub'"]' ).each(function(){
this.checked=selectAll;
});
}
When i uncheck the 'select all' checkbox, i need the all checkboxs generated by f:selectitems to be unchecked and vice versa.
The below code in the change event's javascript gave me an error in the console. Error is "unexpected syntax error ; "
$( 'input[id^="'accord:empListSub'"]' ).each(function(){
this.checked=selectAll;
});
In the network the javascript code appears as
$( 'input[id^="'accord:empListSub'"]' ).each(function(){
this.checked=selectAll;
});
I tried removing the double quote which was of no use.
So could anybody help me out here.
In jquery, When i uncheck the 'select all' checkbox, i need the all checkboxs generated by f:selectitems to be unchecked and vice versa.
And also when i check or uncheck any of the f:selectItems it also has to call another javascript function.
How do i do that?