ashleydw / lightbox

A lightbox gallery plugin for Bootstrap
http://ashleydw.github.io/lightbox
MIT License
1.84k stars 1.3k forks source link

Lightbox doubles every time I click to open #168

Closed arggeo closed 8 years ago

arggeo commented 8 years ago

When I click the link to trigger lightbox for the first time after the page is loaded it opens normally. If I click again then it opens 2 times. If I click one more time in opens 4 times etc. Also if I use jQuery('#mylink').ekkoLightbox(); it automatically opens the lightbox and opens unlimited lightboxes one after another without stopping until I refresh and then starts over. This goes on forever. I 've been searching for a solution for 3 days now but unfortunately can't solve this problem.

Here is a screenshot: http://prntscr.com/9zjqtd

ashleydw commented 8 years ago

Sounds like you have more than one event listener. Post your website / page / jsfiddle.

arggeo commented 8 years ago

I did nothing different than the example on official bootstrap website and your documentation.

I included the full bootstrap.js and ekko-lightbox.min.js.

myscript.js jQuery(document).ready(function(){ jQuery(document).delegate('*[data-toggle="lightbox"]', 'click', function(event) { event.preventDefault(); jQuery(this).ekkoLightbox(); });

html <a id="mylink" href="http://myurl.example" data-toggle="lightbox" title="My Link">

arggeo commented 8 years ago

I found the problem, you were right @ashleydw. For anyone using this plugin in wordpress and the remote content is a sub page of his website make sure you use conditional tags to remove the ekko-lightbox.min.js from the page that loads in the lightbox.