Note that there are some explanatory texts on larger screens.

plurals
  1. POApply jQuery plugin to hidden elements
    primarykey
    data
    text
    <p>I have a page which has a number of hidden divs in it. These divs are hidden using the CSS handler <code>.div {display: none}</code>.</p> <p>Within each of these hidden divs is a jQuery powered slideshow, built using a jQuery plugin called TN3.</p> <p>Each hidden div is linked to a photo which is visible on the page. Clicking on the photo shows the corresponding hidden div and slides it into place. Clicking on the photo again, or on a close button within the hidden div, slides it back up and hides it again. This is done using a simple jQuery show/hide toggle script.</p> <p>My problem is that when you click a photo and the 'hidden' div becomes visible, the jQuery slideshow in the now visible div does not work. </p> <p>I think this is because the script for the slideshow uses a <code>$(document).ready()</code> function. As the hidden divs are not part of the DOM (as they are set to <code>display:none</code>) - the jQuery needed to run the slideshow does not fire.</p> <p>I think this leaves me with two options:</p> <ol> <li><p>Hide the hidden divs on page loading with jQuery, rather than setting CSS to <code>display: none</code>. I think this would mean the hidden divs would all be visible for a fraction of second on page load, and then they get hidden with the jQuery code - that would look clunky and is not desirable.</p></li> <li><p>Somehow set the jQuery code needed to operate the slideshow to fire when the user clicks the photo to toggle the visibility of the hidden div. This is where I come unstuck - I'm not sure how to do this.</p></li> </ol> <p>My knowledge of JavaScript is limited to jQuery, and generally limited to using functions that have <code>$(document).ready()</code>. I don't know how to trigger the code on another event other than the page loading.</p> <p>The code for the slideshow is below.</p> <p>Any ideas would be much appreciated</p> <pre><code>$(document).ready(function () { $('.tn3-gallery').tn3({ image: { transitions: [{ type: "fade", easing: "easeInQuad", duration: 423 }] }, thumbnailer: { overMove: false }, mouseWheel: false }); }); // end ready </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    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.
 

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