I have a page which has a number of hidden divs in it. These divs are hidden using the CSS handler .div {display: none}.
Within each of these hidden divs is a jQuery powered slideshow, built using a jQuery plugin called TN3.
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.
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.
I think this is because the script for the slideshow uses a $(document).ready() function. As the hidden divs are not part of the DOM (as they are set to display:none) - the jQuery needed to run the slideshow does not fire.
I think this leaves me with two options:
Hide the hidden divs on page loading with jQuery, rather than setting CSS to
display: none. 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.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.
My knowledge of JavaScript is limited to jQuery, and generally limited to using functions that have $(document).ready(). I don't know how to trigger the code on another event other than the page loading.
The code for the slideshow is below.
Any ideas would be much appreciated
$(document).ready(function () {
$('.tn3-gallery').tn3({
image: {
transitions: [{
type: "fade",
easing: "easeInQuad",
duration: 423
}]
},
thumbnailer: {
overMove: false
},
mouseWheel: false
});
}); // end ready