Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Featherlight - how to open lightbox with javascript?

Using Featherlight and JQuery, I have a lightbox :

  <div class="lightbox" id="mylightbox"> Text to display in box </div>

Instead of using a link, that I do not need, to open it as :

  <a  href="#" data-featherlight="#mylightbox">Open element in lightbox</a>

I would like to trigger it in a javascript function :

    $('lightbox.mylightbox').featherlight({
        });

I tried with featherlight.click or featherlight.open but it did not work. Thxs for your help.


2nd Edit : Just found the solution as calling $('lightbox... only sets configuration parameters. I made a forced click on the <a id="f1" ... > link through the following javascript function :

$('f1').click();

like image 295
clovisti Avatar asked Jul 23 '14 22:07

clovisti


1 Answers

Featherlight is the lightbox plugin used here. No need to force a click.

HTML

<div id="mylightbox">Text to display in box</div>

JS

$.featherlight($('#mylightbox'), {});

Demo

like image 190
TPoy Avatar answered Oct 28 '22 18:10

TPoy