我们如何<p:selectOneMenu>
使用 JavaScript/jQuery 获取 PrimeFaces 的选定值?
我试图以这种方式获取它,但它没有进入 if 条件,这意味着元素的 ID 不正确。
<h:head>
<script>
function showDialog() {
alert("insdie function");
if($('#someSelect').val() == 'India') {
dlg.show();
alert("after function");
}
alert("outside function");
}
</script>
</h:head>
<h:body>
<h:form>
<p:panel>
<h:panelGrid columns="2">
<p:selectOneMenu
id="someSelect"
value="#{testController.countryName}"
<f:selectItem itemLabel="Select One" itemValue="" />
<f:selectItems value="#{addPatientProfileBB.patStatusSelect}"
itemLabel="#{testController.countryName}"
itemValue="#{testController.countryNameId}" />
<p:ajax process="someSelect" update="dialog" oncomplete="showDialog()"/>
</p:selectOneMenu>
</h:panelGrid>
<p:dialog id="dialog" header="Login" widgetVar="dlg">
<h:form>
<h:panelGrid columns="2" cellpadding="5">
<h:outputLabel for="username" value="Username:" />
<p:inputText id="username" required="true" label="username" />
</h:panelGrid>
</h:form>
</p:dialog>
</p:panel>
</h:form>
</h:body>