ashleydw / lightbox

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

Accessing content in modal box? #154

Closed Toccamonium closed 8 years ago

Toccamonium commented 8 years ago

Hi, I want to access content within the modal box like this, but it's not working, any idea?

$(document).delegate('*[data-toggle="lightbox"]', 'click', function(event) { event.preventDefault(); var name = $(".vp-name").text(); $(this).ekkoLightbox({ onShown: function() { var lb = $(".modal-body").find("span"); $(lb).text(name); } }); });

best regards

ashleydw commented 8 years ago

Look at using onContentLoaded instead

Toccamonium commented 8 years ago

Thanks for answering my question so quickly. Unfortunately onContentLoaded nothing happend at all. I was testing this with a simple alert("")...

I tried this but it isn't working as well: ... $(this).ekkoLightbox({ onContentLoaded: function() { var lb = this; $(lb.modal_content).css("background","red") } }); ...

Do you have an simple working example :)

ashleydw commented 8 years ago

All the docs (http://ashleydw.github.io/lightbox/) have events for onShown and onContentLoaded. Open the console for the output, the source will show you how it is done