我有一个 Primefaces 命令按钮,它在其 onComplete 中调用一个数据表过滤器。数据表由 widgetVar 引用:
<p:commandButton id="addFishBtn"
title="Add Fish"
update="fishForm:FishTbl"
action="#{backingBean.addFish()}"
oncomplete="fishTable.filter()"/>
问题是,当按下这个按钮时,fishTable 并不总是存在。它不存在,应用程序就会卡住。我从其他 SO 问题中尝试了类似的方法:
oncomplete="if(typeof(fishTable) != 'undefined') {fishTable.filter()}"
但它似乎并没有做任何事情。是否有任何正确的方法来检查 widgetVar 当前是否有任何值?
谢谢!
最佳答案
您可以使用以下内容
if(PrimeFaces.widgets['fishTable']) {
//widgetVar does exist
PF('fishTable').filter();
}
关于javascript - 检查 PrimeFaces widgetVar 是否存在,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24475431/