How to hide

after it displayed the messages?

前端 未结 4 518
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-19 14:37

I am working on JSF application in primefaces in that i am showing an information to the user via .

So when the user click submit the

相关标签:
4条回答
  • 2021-01-19 14:42

    Worked for me for <p:fileUpload>, which was in <p:dataList> and <h:panelGrid> elements.

        <p:fileUpload...
               oncomplete="setTimeout(function() { $('[id$=mr-upload-messages]').hide(1000); }, 2000);">
    
    ...
        <p:messages id="mr-upload-messages" showDetail="true" showSummary="false" closable="true"/>
    

    I have used jQuery $('[id$=mr-upload-messages]' to find id's which ends with mr-upload-messages, because Primefaces adds it's unique identifier at the beginning of id.

    0 讨论(0)
  • 2021-01-19 14:52

    <p:messages id="msgs"> is ultimately rendered as <div id="msgs"> and its contents is then updated with the factual messages to the user.

    If you want to clear the message screen after some delay you should use the JavaScript setTimeout function after ajax call has been completed:

    <p:commandButton ... 
            oncomplete="setTimeout(function() { $('#msgs").html(''); }, 3000);" />
    

    The second parameter of setTimeout function is the delay in milliseconds.

    The other alternative is to use <p:growl> instead.

    0 讨论(0)
  • 2021-01-19 14:56

    I came across the attention, and did it this way:

    function hideMsg(){
    $("#msg").delay(1000).hide(1000);
    }
    
    oncomplete="hideMsg()"
    
    0 讨论(0)
  • 2021-01-19 14:58

    $('#msgs').html(''); immediately hide in 3 seconds but if you want to hide slowly as jquery hide method do this..

    <p:commandButton ... 
            oncomplete="setTimeout(function() { $('#msgs').hide(1000); }, 3000);" />
    

    hide(1000); hiding motion will be completed in 1 second

    0 讨论(0)
提交回复
热议问题