This may be super simple - but I'm struggling to spot what's going on.
On the JS Fiddle: http://jsfiddle.net/3hHAX/
There are two links output to 'Open video modal'.
As the link text suggests these two links should open a model pop-up with the youtube video contained.
This is using the prettyphoto library from: http://www.no-margin-for-errors.com/projects/prettyphoto-jquery-lightbox-clone/
For some reason the click event doesn't trigger on first click. But works on second.
(Haven't included the CSS so doesn't look very modal, but you'll see the content load in below at least for purposes of demo).
Can anyone suggest what's going wrong?
Thanks,
Steve
Trigger the click event after you initialize it, and only allow it to be initialized once.
Demo: http://jsfiddle.net/3hHAX/3/
Edit for clarification:
This is a very common way of initializing a plugin on dynamic elements. As noted, it is better to initialize on dom ready if your elements are not dynamic.
Note:
.live
is depreciated, you should really be using.on
Thanks Guys,
Both responses helped me ultimately solve it.
End solution in the updated JSFiddle:
http://jsfiddle.net/3hHAX/6/
Seems prettyPhoto attaches it's own on click event, and just needed applying to those dom elements.
Thanks, Steve