简体   繁体   English

值变更事件和点击事件

[英]Value Change Event and Click Event

I have a JSF page with value change listeners on input field, and a button to save the changes. 我有一个JSF页面,在输入字段上有值更改侦听器,还有一个按钮来保存更改。 When I change a value on them and tab out of the field, the validation fires and everything works fine. 当我更改它们的值并跳出字段时,验证将触发,并且一切正常。 But when I change a value and, without tabbing out, click on the Save button, the value change event fires, but its Button's click action is not fired. 但是,当我更改一个值,并且不分页地单击“保存”按钮时,将触发值更改事件,但不会触发其Button的click动作。 How to get around this so that I can have both events firing sequentially? 如何解决这个问题,以便让我依次触发两个事件?

With "p:clientValidator" in the fields you want to validate and the property validateClient="true" in your p:comandButton primefaces does the work for you. 在要验证的字段中使用“ p:clientValidator”,并在p:comandButton primefaces中使用属性validateClient =“ true”可以为您完成工作。

Take a look at this example: validate client 看一下这个例子: 验证客户端

My guess is that its beacause of multiple ajax requests... 我的猜测是由于多个ajax请求...

What happens is when you clicking on your submit button your input filed is getting blurred and thus triggering its chnage event which in turn sends an ajax to your server which in turn making your submit button ajax request to get lost (you can't send two ajax at once/one click) 发生的事情是,当您单击“提交”按钮时,输入文件变得模糊,从而触发其chnage事件,这又将ajax发送到您的服务器,这又使您的提交按钮ajax请求丢失(您不能发送两个一次/一键ajax)

I suggest you to replace your input change event into keyup event to prevent your double ajax sending scneario 我建议您将输入更改事件替换为keyup事件,以防止双ajax发送脚本

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM