diff --git a/jquery.lightbox.js b/jquery.lightbox.js index adcc21e..b2f7d31 100644 --- a/jquery.lightbox.js +++ b/jquery.lightbox.js @@ -34,19 +34,23 @@ init: function (items) { plugin.items = items; - plugin.selector = "lightbox-"+Math.random().toString().replace('.',''); var id = 'lightbox-' + Math.floor((Math.random() * 100000) + 1); if (!plugin.lightbox) { - $('body').append( - '' - ); - - plugin.lightbox = $("#"+id); + plugin.lightbox = $('body').find('.bodyGlobalLightbox'); + + if(plugin.lightbox.length === 0){ + $('body').append( + '' + ); + + plugin.lightbox = $("#"+id); + } + plugin.caption = $('.lightbox__caption', plugin.lightbox); }