primefaces单选按钮仍然用jquery“检查”

时间:2012-03-26 15:46:48

标签: jquery button primefaces radio

我正在使用Primefaces 3.2和cupertino主题:

<context-param> 
    <param-name>primefaces.THEME</param-name> 
    <param-value>cupertino</param-value> 
</context-param>

当我点击一个单选按钮时,它会被检查..但是如果我尝试用jquery取消检查它仍然被检查..我在底部链接中使用一个简单的javascript函数。

screen image

跟随xhtml页面:

<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:p="http://primefaces.org/ui">

  <h:head>
    <title>Custom Radio Test</title>
    <script type="text/javascript">

      function uncheckTest() {

      var myRadio =  $("#mF\\:vB\\:0\\:vBI\\:0\\:ITRadioGrp\\:0");
       alert("RADIO : " + myRadio.get(0).id + "     CHECKED :" + myRadio.is(':checked'));
        myRadio.removeAttr("checked");  
        myRadio.prop('checked', false);

        alert("RADIO : " + myRadio.get(0).id + "     CHECKED :" + myRadio.is(':checked'));

      }

    </script>
  </h:head>

  <h:body>

    <h:form id="mF" >

      <div>

        <ui:repeat id="vB" value="#{testBean.groupOfVB}" var="aViewBoxPrice" varStatus="vbpindex" >

          <ui:repeat id="vBI" value="#{testBean.groupOfIT}" var="aItinerary" varStatus="itiindex" >

            #{itiindex.index + 1}° group

            <p:selectOneRadio value="#{testBean.radioSelectedValue}" id="ITRadioGrp" layout="custom" >
              <f:selectItems value="#{testBean.selectItems}" />
            </p:selectOneRadio>

            <ui:repeat id="vBGOF" value="#{testBean.groupOfFlights}" var="aFlight" varStatus="gofIndex">
              <p:radioButton for=":mF:vB:vBI:ITRadioGrp" itemIndex="#{gofIndex.index}"/> #{aFlight}
              <br />
            </ui:repeat>

            <br />
          </ui:repeat>

          <br />
        </ui:repeat>

        <a href="javascript:uncheckTest()">UNCHECK</a>

      </div>


    </h:form>

  </h:body>

</html>

我无法理解为什么.. 谢谢!

1 个答案:

答案 0 :(得分:0)

这是因为主要的CSS ..我不得不用jquery取消选中收音机..