Mahmoud Saleh
Mahmoud Saleh

Reputation: 33605

Execute effect if component is displayed only

I have a panel that i want to execute a hide effect on it if it's shown only, and if it's hidden, the effect shouldn't work.

 <h:outputLink id="open_link" value="#" styleClass="underline">
            Click To Open   

<p:effect for="blank_panel" type="blind" event="click" speed="2000">
        <f:param name="mode" value="'hide'" />
</p:effect>

<p:effect type="blind" event="click" for="display_tabs" delay="1000">
    <f:param name="mode" value="'show'" />
</p:effect>

</h:outputLink>

    <h:panelGroup id="blank_panel" layout="block">

    </h:panelGroup>

I want when clicking on the link for the second time (blank_panel is hidden in this case) the effect for the blank_panel is not executed

     <!-- executed only if the blank_panel is shown -->
     <p:effect for="blank_panel" type="blind" event="click" speed="2000">
        <f:param name="mode" value="'hide'" />
</p:effect>

Upvotes: 0

Views: 362

Answers (1)

Daniel
Daniel

Reputation: 37061

INMO you really better use jQuery effects, but...

Since you want to use p:effect of primefaces I think you should play with two <h:outputLink with their visibility , pressing one should hide it and show the second <h:outputLink and vice versa...

 <h:outputLink id="open_link" 
    onclick="$('#open_link').hide();$('#open_link2').show();" value="#" 
    styleClass="underline">
            Click To Open   
    <p:effect....
    <p:effect....
 </h:outputLink>


 <h:outputLink id="open_link2"
    onclick="$('#open_link2').hide();$('#open_link').show();" value="#" 
    styleClass="underline">
            Click To Open   
    <p:effect...
 </h:outputLink>

Not sure about the ids... (if you don't use prependId="false" or etc...)

Upvotes: 1

Related Questions