Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't make FancyBox works proprely when it's inside a container initially not renderd
    primarykey
    data
    text
    <p>I been trying to solve this for several hours today. I have reach (in some way) a solution but is not working as expected.</p> <p>I'm new into the jQuery's world so i'll try to be clear. In my example i have a xhtml page that include another xhtml page inside with the <code>&lt;ui:include&gt;</code> tag. The page that is included i'ts not originally rendered (due to all the pictures that contains). When it's rendered via a <code>&lt;p:commandLink&gt;</code> the page is shown with all the pictures correctly. Every picture is a <code>&lt;h:ouputLink&gt;</code> that shows a fancyBox, but with a behaviour a little bugged.</p> <p>When the included page is finally rendered and i click for the first time the <code>&lt;h:ouputLink&gt;</code> the fancyBox doesn't show, but subsequent clicks opens the fancyBox and it works properly. I can't figure why. Im using jsf2, PrimeFaces 3.02, FancyBox 1.7. My code:</p> <p>The main.xhtml</p> <pre><code> &lt;--Main xhtml--&gt; &lt;h:form id="myForm"&gt; &lt;h:panelGrid id="panelGridMain" rendered="#{myBean.actualPage eq 'main'}"&gt; &lt;p:commandLink id="showIncludedPage" actionListener="#{myBean.setPage('test')}" update="@form"&gt; &lt;h:graphicImage value="/Image/TbnPic1.jpg"/&gt; &lt;/p:commandLink&gt; &lt;/h:panelGrid&gt; &lt;h:panelGroup id="myTestPanel" rendered="#{myBean.actualPage eq 'test'}"&gt; &lt;ui:include src="test.xhtml" /&gt; &lt;/h:panelGroup&gt; &lt;/h:form&gt; </code></pre> <p>Test.xhtml</p> <pre><code>&lt;ui:component xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:p="http://primefaces.org/ui" xmlns:c="http://java.sun.com/jsp/jstl/core"&gt; &lt;h:outputLink value="/Images/Pic1.jpg" id="example1" title="" &gt; &lt;h:graphicImage alt="example1" value="/Images/TbnPic1.jpg" /&gt; &lt;/h:outputLink&gt; &lt;/ui:component&gt; </code></pre> <p>Finally my jQuery code</p> <pre><code>$(document).ready( function() { $("#myForm\\:example1").live("click",function(e) { alert(e.isDefaultPrevented()); if (! e.isDefaultPrevented()){ e.preventDefault(); } $(this).fancybox(); }); }); </code></pre> <p>Some aclarations: </p> <p>*I red that <code>.on()</code> is recommend but it didn't work for me, i need to do more tests.</p> <p>*I had to add the e.preventDefault() to my .js because when i clicked the link to pop-up the fancyBox , the link was redirecting to the url containing the photo (eg: localhost:8080/../Images/Pic1.jpg)</p> <p>*if the page was originally rendered the fancyBox worked properly.</p> <p>Thanks for any help, i hope you can understand the problem =)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload