Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

Hash not working on selector #2444

Open
StyXman opened this issue Apr 5, 2020 · 6 comments
Open

Hash not working on selector #2444

StyXman opened this issue Apr 5, 2020 · 6 comments

Comments

@StyXman
Copy link

StyXman commented Apr 5, 2020

Describe the bug
Assuming:

  • images don't have data-fancybox attribute (my gallery generator is removing those; I know, it's kinda also a bug in it too).
  • fancybox is launched with a selector because the images are generated (I think; this is what selector is for, and it's not working without it; I already tried $('[...]').fancybox(...));
  • with hash="image" (BTW, I think the doc is a little bit short here, it took me a while to figure out that for this method of starting fancybox I should set it to a string).
  • we arrive to the gallery with an image hash.

Then triggerFromUrl() fails because it's using $("[data-fancybox='" + $.escapeSelector(url.gallery) + "']") instead of selector.

To Reproduce
Steps to reproduce the behavior:

  1. Go to http://dionecanali.hd.free.fr/~mdione/tmp/#image-2

Expected behavior
The lightbox opens in the image.

Desktop:

  • OS: Linux Debian Sid
  • Browser: Firefox
  • Version: 74.0
@StyXman
Copy link
Author

StyXman commented Apr 6, 2020

Here's the relevant line:

$("[data-fancybox='" + $.escapeSelector(url.gallery) + "']")

@fancyapps
Copy link
Owner

fancyapps commented Apr 6, 2020

Hi,

Hash plugin grabs URL.hash and looks if any element has data-fancybox attribute with the same value. So, in order for this feature to work, your elements have to have data-fancybox attribute.

FYI, I am right now working on hash plugin for v4 (you can preview it here https://fancyapps.com/next/) so it might work in the future like you expect, but for v3 you have to use data-fancybox attributes, sorry about that.

@fancyapps
Copy link
Owner

btw, nothing prevents you from starting fancybox manually, e.g., you could either trigger click event on corresponding link or use $.fancybox.open() inside $(document).ready()

@chasdevlin
Copy link

Good to know when I try to implement this for WP (if I knew how!).

@StyXman
Copy link
Author

StyXman commented Apr 6, 2020

I understand. Now, If I would like to hack this (please confirm my finding is correct), how could I get a reference to opts.selector so I can use it in that line?

@StyXman
Copy link
Author

StyXman commented Apr 6, 2020

Ah, I wrote that question before I got your other answer. I'll try that.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants