selectCheckboxMenu无法获取已选中复选框的计数

Par*_*rag 2 jquery primefaces

Primefaces 5.0 selectCheckboxMenu组件问题,无法在jQuery中获取复选框的id以获取已选中复选框的计数.

我想用selectCheckboxMenu组件中选中的复选框的计数更新标签文本.我尝试了两种方式

  1. 阿贾克斯
  2. 获取复选框ID的jQuery.

下面是我在.xhtml文件中的代码.在ajax调用之后,我发现了一个类似于this.closer的错误在primefaces.js第22行中未定义.

  <p:selectCheckboxMenu id="pioDocType"
                        value="#{pioReportActionBean.selectedOutPutData}"
                        label="#{pioReportActionBean.lbl_docType}" filter="true"
                        filterMatchMode="startsWith" panelStyle="width:250px"  styleClass="rep_checkbox" widgetVar="myCheckbox" >
     <f:selectItems value="#{pioReportActionBean.inPutData}"
                    var="outPutData" itemLabel="#{outPutData.displayName}"
                    itemValue="#{outPutData.displayId}" />

     <p:ajax event="change" listener="#{pioReportActionBean.populateLabelDocType}"
             update="pioDocType" />

     </p:selectCheckboxMenu> 
Run Code Online (Sandbox Code Playgroud)

jQuery代码..

var count = $("#pioDocType input:checked").length;
alert(count);
count = $("#myCheckbox:checked").length;
alert(count);
count = $("input.rep_checkbox .ui-selectcheckboxmenu-panel .ui-selectcheckboxmenu-header .ui-chkbox-box:checked").length;
alert(count);
Run Code Online (Sandbox Code Playgroud)

我使用的是spring 3,Primefaces 5.0,JDk 7.

Hat*_*mam 5

你可以试试这个

var count = PF('myCheckbox').inputs.filter(":checked").length;
//change label
PF('myCheckbox').jq.find('.ui-selectcheckboxmenu-label').text(count + ' selected');
Run Code Online (Sandbox Code Playgroud)