[英]Set Primefaces inputText value from Javascript and have ajax fire
I have a primefaces(v10) input text which I need to set from a javascript function and also have an ajax event fire on blur.我有一个 primefaces(v10) 输入文本,我需要从 javascript function 设置它,并且还有一个 ajax 事件在模糊时触发。 In my code I have this, but have been unsuccessful in getting the ajax function to fire.
在我的代码中,我有这个,但未能成功触发 ajax function。
<h:form id="myForm">
<p:inputText id="myText" widgetVar="myTextVar" value="#{myBean.myText}">
<p:ajax event="blur" listener="#{myBean.updateMyText}" update="myForm"/>
</p:inputText>
</h:form>
I can set the inputText using:我可以使用以下方法设置 inputText:
document.getElementById("myForm:myText").value="The Value"
But I'm wondering if I need to use something from the PF() Widget API?但我想知道我是否需要使用 PF() 小部件 API 中的某些东西?
Its easy.这很容易。 Just use the widget...
只需使用小部件...
PF('myTextVar').jq.val('The Value').trigger('change');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.