Controlling primefaces dialog from javascript

佐手、 提交于 2019-12-13 04:32:21

问题


I try to control primefaces display show and hide from java script on bean validation failure, but its not working. As suggested in forums have tried with widgetVar name of the component in javascript and even tried with id of the component but failed.

XHTML

<p:dialog header="Modal Dialog" id="mglasspaneid" showHeader="false" closable="true" resizable="false" draggable="false" widgetVar="mglasspane" style="height: 50px !important;" modal="true">
        <span id="loading" draggable="false" style="height: auto !important;">Loading</span>
</p:dialog>

Javascript

<script>
        function handleComplete(data) {
            if (data.status === 'success') { 

               console.log(document.getElementById('validation-failed').value);
               mglasspane.hide();

            }else{
                console.log(document.getElementById('validation-failed').value);
                mglasspane.show();
            }                
        }
</script>

回答1:


From PrimeFaces 5.0 you must call any component with the PF function (i.e. PF('widgtVar') instead of widgetVar which has already been deprecated in 4.0). Source here.

Replacing mglasspane.hide(); by PF('mglasspane').hide(); should work.


More information about the PF function here



来源:https://stackoverflow.com/questions/31108476/controlling-primefaces-dialog-from-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!