我没有找到 oncomplete
在标准 JSF 中的 PrimeFaces 中的某些标签中可用的属性 <h:commandButton>
.
如何在使用 <h:commandButton>
时获得类似 oncomplete 的功能?
最佳答案
自素面 oncomplete
相当于普通的 JSF success
事件(有关更多详细信息,请查看 this answer comments ,您应该按以下方式使用 success
事件:
内联解决方案
<h:commandButton id="someId" action="#{myBean.myAction}">
<f:ajax onevent="function(data) { if (data.status === 'success') { alert('complete'); }"
render="whatevet"></f:ajax>
</h:commandButton>
另一个更清洁的解决方案是使用 js 函数
<h:commandButton id="someId" action="#{myBean.myAction}">
<f:ajax onevent="myJsFunction"
render="whatevet"></f:ajax>
</h:commandButton>
在你的 js 文件中添加
function myJsFunction(data) {
if (data.status === 'success') {
alert('complete');
}
}
如果您正在寻找一种检测非 ajax 提交完成的方法,您可以从这里采用以下想法 Detecting the File Download Dialog In the Browser
最简单的解决方案是使用
$(document).ready(function () {
// check if some condition is meet and do something...
});
关于jsf - JSF <h :commandButton> 中 PrimeFaces 的 oncomplete 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15805825/