I use fancybox to display some images in the gallery. I have a main image and a bunch of thumbnails under it. If you click on the main image, it should show a fancybox, but if you click on the thumbnail, it will replace the main image. I hooked up the main image transform somewhere else, but the problem is that I want to stop the fancybox display when I click on the thumbnail. I have this code:
$(this).fancybox({
onStart: function(selectedArray, selectedIndex, selectedOpts) {
var element = selectedArray[selectedIndex];
if ($(element).parent('li').length > 0) {
$.fancybox.cancel();
$.fancybox.close();
$(element).click();
}
}
});
});
but cancel and close do not work. I would not be surprised if close () is redundant provided that cancel () works ...
thank
Robb
edit: Here are some html for the main image:
<a href="/uploadedImages/About_Something/Carousel/Landing_mainImage.png" id="ctl00_ContentPlaceHolder1_aMainImage" class="fancyBox" rel="gallery">
<img id="ctl00_ContentPlaceHolder1_imgMainImage" src="/uploadedImages/About_Something/Carousel/Landing_mainImage.png" alt="1" style="border-width:0px;" />
</a>
and here is one of the thumbnails:
<a href="/uploadedImages/About_Something/Carousel/Landing_mainImage_2.png" class="fancyBox" rel="gallery">
<img src="/uploadedImages/About_Something/Carousel/Landing_mainImage.png " alt="/uploadedImages/About_Something/Carousel/Landing_mainImage.png " />
</a>
and then more javascript looks like this:
$('a.fancyBox').each(function(i) {
if ($(this).parent('li').length > 0) {
$(this).click(function(e) {
e.preventDefault();
});
}
$(this).fancybox({
onStart: function(selectedArray, selectedIndex, selectedOpts) {
var element = selectedArray[selectedIndex];
if ($(element).parent('li').length > 0) {
$.fancybox.cancel();
$.fancybox.close();
$('#fancy_close').trigger('click');
$(element).click();
}
}
});
});