更改f:selectitems时调用Javascript函数

更改f:selectitems时调用Javascript函数,javascript,jquery,jsf,primefaces,Javascript,Jquery,Jsf,Primefaces,我不熟悉jquery。我的项目涉及PrimeFaces4.0、JSF2.1(xhtml) 我有一个全选布尔复选框和一个selectmanycheckbox,它使用从服务器端检索的列表填充 <p:tab title="Service Status" > <p:selectBooleanCheckbox itemLabel="Select All" value="#{myBean.selectAllStatus}" id="selectAll

我不熟悉jquery。我的项目涉及PrimeFaces4.0、JSF2.1(xhtml)

我有一个全选布尔复选框和一个selectmanycheckbox,它使用从服务器端检索的列表填充

<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>

当我取消选中“全选”复选框时,我需要取消选中f:selectitems生成的所有复选框,反之亦然

更改事件的javascript中的以下代码在控制台中给了我一个错误。 错误为“意外语法错误”

在网络中,javascript代码显示为

$( 'input[id^=&quot;'accord:empListSub'&quot;]' ).each(function(){
     this.checked=selectAll;
});
我试着删除没有用的双引号

有人能帮我吗

在jquery中,当我取消选中“全选”复选框时,我需要取消选中由f:selectitems生成的所有复选框,反之亦然

而且,当我选中或取消选中任何f:selectItems时,它还必须调用另一个javascript函数

我该怎么做?

尝试在jQuery中使用来设置checked属性

 $( 'input[id^='+accord:empListSub+']' ).prop("checked",selectAll);

问题在于组件引用

$( 'input[name^=accord\\:empListSub]' ).each(function(i,obj){
    $('div .ui-chkbox-box').addClass('ui-state-active');
    $('span .ui-chkbox-icon').addClass('ui-chkbox-icon ui-icon ui-icon-check ui-c');
 );

我认为问题在于Primefaces对复选框使用主题化,所以不能用普通的jquery方式。您必须在容器上显示/隐藏支票图像。我试过了,但失败了,但我认为你可能忘记告诉PrimeFaces版本。PrimeFaces 4.1不存在。至少,不是最终/官方版本。对不起:)…我错了。。
 $( 'input[id^='+accord:empListSub+']' ).prop("checked",selectAll);
$( 'input[name^=accord\\:empListSub]' ).each(function(i,obj){
    $('div .ui-chkbox-box').addClass('ui-state-active');
    $('span .ui-chkbox-icon').addClass('ui-chkbox-icon ui-icon ui-icon-check ui-c');
 );