ashleydw / lightbox

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

How can I catch events from the modal? #173

Closed Achtel closed 8 years ago

Achtel commented 8 years ago

I've added a delete icon to the data-footer attribute which renders just fine but I'm now struggling to figure out how to capture the click event from it.

I'm using this within a Meteor app so I had hoped I could use a template event but that doesn't seem to fire.

Any pointers as to how I could achieve this?

ashleydw commented 8 years ago

Just use a normal jquery event to catch it, a global listener is probably easiest.

http://api.jquery.com/on/ http://api.jquery.com/delegate/

Achtel commented 8 years ago

.delegate() worked where .on() wouldn't. Thanks for the hint.

$(document).delegate(".delete-image", "click", function() {
      console.log("button clicked woohoo");
    });
Achtel commented 8 years ago

Sorry to ask another daft question - I've implemented the delete method now which is all working fine: user clicks on the image, modal pops up with button, user clicks button, method is invoked, image gets deleted - last thing I want to do on successful delete is close the modal but how can I invoke the .close() function / which element do I grab?

$('.ekko-lightbox').close() doesn't work...

ashleydw commented 8 years ago

First image under http://ashleydw.github.io/lightbox/#navigateTo

Look at the page source for closeit

Achtel commented 8 years ago

Worked, thanks again for the hint.