I want to hide my icon/button on submission of dialog box...My code stops working when i place my icon/button inside <h:form>
This is code for my icon
<h:outputLink id="loginLink" value="javascript:void(0)"
                onclick="dlg.show()">
            <p:graphicImage value="/images/logo.png" />
</h:outputLink>
this is code for dialog box
<p:dialog id="dialog" header="Login" widgetVar="dlg">
    <h:form>
        <p:commandButton value="Login"
                oncomplete="handleLoginRequest(xhr, status, args)" />
    </h:form>
</p:dialog>
now this is my script
<script type="text/javascript">
function handleLoginRequest(xhr, status, args) {
        dlg.hide();
    jQuery('#loginLink').fadeOut();
    alert("This is working fine");
}
</script>
Everything works fine this way.. alert("This is working fine"); is working fine and my icon also gets fade out....
But when I place my icon inside <h:form></h:form> icon doesn't fade out(Script is working fine but unable to reach my icon inside <h:form>
Ex:
<h:form>
    <h:outputLink id="loginLink" value="javascript:void(0)"
            onclick="dlg.show()">
        <p:graphicImage value="/images/logo.png" />
    </h:outputLink>
</h:form>
This way I am facing problem :(
P.S : using <h:form> is must for me as I am going to place my code in <p:menuitem> which needs to be placed inside <h:form> 
 
     
    