【发布时间】:2012-03-26 15:46:47
【问题描述】:
我正在使用带有 Cupertino 主题的 Primefaces 3.2:
<context-param>
<param-name>primefaces.THEME</param-name>
<param-value>cupertino</param-value>
</context-param>
当我点击一个单选按钮时,它会被选中.. 但如果我尝试用 jquery 取消选中,它仍然处于选中状态.. 我在底部链接中使用了一个简单的 javascript 函数。
跟随 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>
我不明白为什么.. 谢谢!
【问题讨论】:
标签: jquery button primefaces radio