Codeinwp / Nivo-Lightbox-jQuery

A simple, flexible, responsive, retina-ready jQuery lightbox plugin.
http://dev7studios.com/nivo-lightbox
MIT License
157 stars 87 forks source link

For Inline -- have a class to use on link to close Lightbox #56

Open amiga-500 opened 8 years ago

amiga-500 commented 8 years ago

I notice there is no feature to close the inline lightbox besides the "X" at the top right corner. If someone wanted to have a button in the popup then it is impossible since the "X" uses a class that draws the "X" image, etc. Have an indepenent class that the user can use on their own anchors so when clicked it closes the lightbox.

benjaminprojas commented 8 years ago

@brand404 I had this same issue, and found a workaround for it:

// first create a variable to store the lightbox once it is created
var lightbox;

// then setup the lightbox
$( 'a.nivo-lightbox' ).nivoLightbox();

// when the lightbox element is clicked, we want to assign the object to the variable
$( 'a.nivo-lightbox' ).click( function() {
  lightbox = $(this).data('nivoLightbox');
} );

// now we can use an element inside the lightbox to destroy the lightbox when clicked
$( 'body' ).on( 'click', 'a.nivo-lightbox-close', function() {
  lightbox.destructLightbox();
} );
noindie commented 7 years ago

can you please explain how to use this?