New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
gallery array length miscalculated #769
Comments
My guess is that Colorbox (jQuery) is correct when determining how many elements in your document match your selector. I feel like you probably overlooked something, or that you have some invalid markup that is being fixed by the browser in a way you didn't anticipate. Can you provide a demo of this behavior? |
Many thanks for the quick reply! There's really only three selectors in the document. But the error is not really limiting the functionality of the page, it's just a little confusing, so I'll put it online tonight with the current behaviour. Will get back to you with the link then. Thanks again! |
Hi again - the page is online now, you can have a look at the problem at, eg, http://kunst-mentoring.de/archives/kuenstlerinnen/schneider-kathrin If you look at the slider, you'll see three navigation points (top left of slider). If you click on the image and open colorbox, you'll see that the gallery shows "Image 1 of 5", and I can only find three selectors in the source code. Thanks for your help! |
Try opening your browser's developer console and run the following: |
Quick suggestion, maybe you could store the jQuery collection you want to use with Colorbox before assigning the liquid-slider. Here's an example (replaces your current code blocks for assigning liquid-slider and colorbox):
I can't be positive that will be a complete fix because I don't know how often liquid-slider rebuilds the DOM after it is called (if ever), but I expect it to work. |
That's great! Thanks a lot for the suggestion! And for colorbox, of course! |
Notice that I create $gallery first, then assign liquidSlider, then assign Colorbox. If Colorbox had simply been assigned before liquidSlider you would probably have the same problem because liquidSlider would clone the elements Colorbox had been assigned to. |
Thanks again! I've updated the code for the link I gave above and was hoping it would work. And it kind of does! But here's the weird thing - while the console shows me the three-element array instead of the previous five-element array when I log $gallery, from the setup to after the variable/colorbox is called by the tap event - but the colorbox still counts to five. |
Oh... remove the |
And another round of thanks! That's it. Works like a charm now! |
Hi -
I'm opening a colorbox gallery via a separate link as explained in the FAQ. It works fine, except that, for some reason, the opened colorbox always gives a gallery array length that exceeds the actual amount of rel="abc" selectors. Say there's three anchors and images in the document with the respective selector, then the opened colorbox will have an array of five images, the first two being added again at the end of the array.
This is the code I'm using to call the gallery (on a touchswipe-slider "tap" event) -
var $gallery = jQuery("a[rel=gal_link]").colorbox(); $gallery.eq(0).click();
And this is the selector code -
<a class="cboxgrouped cboxElement" rel="gal_link" href="'.$image_full[0].'"><img src="'.$image_medium[0].'" alt=".$caption." title="'.$caption.'" /></a>
Is this a bug? I assume I'm doing something wrong, maybe someone has an idea how to fix this problem.
Thanks!
The text was updated successfully, but these errors were encountered: