0

I want to dynamically generate a fancybox popup on one of my page. The idea is, I generate an image, apply fancybox and it, and then directly show the popup

At the moment, I do:

// Image generation...
// At the end I get the image then apply the fancbox
jQuery('a#myimage').fancybox();

// Then I would like the popup to appear directly so I do...
jQuery('a#myimage').click();

... But it doens't work because sometimes, the fancybox is not yet active when the click fires ! Is there a way to execute the click when the fancybox has fully initialized ?

Thanks in advance

sabithpocker
  • 15,274
  • 1
  • 42
  • 75
Julien
  • 51
  • 1
  • 2
  • are you dynamially adding images? if yes you might need to check load event of image. In the above case click will be triggered only after executing fancybox(), that is how javacript works. Create a fiddle so that we can take a look at actual issue. – sabithpocker Jul 05 '12 at 16:24
  • you shouldn't have problems with fancybox v2.x. On the other hand, fancybox v1.3.4 doesn't support dynamically added elements. Check a workaround here for that version http://stackoverflow.com/a/9084293/1055987 – JFK Jul 05 '12 at 16:30
  • Thanks for the answers; fancyBox 2, considering licensing options, is not my first choice then. I will try your solution JFK, i.e, the workaround for the fb 1.3x – Julien Jul 06 '12 at 05:41

0 Answers0