Close all open Featherlight windows before opening a new one

1.9k views Asked by At

I'm registering multiple featherlight instances upon page-load

jQuery('.feedback').featherlight(jQuery( "#feedback-box" ), { closeIcon: 'close'});
jQuery('#imprint').featherlight(jQuery( "#imprint-box" ), { closeIcon: 'close'});

When one box is opened I would like to close all other open ones before.

How can I achieve this?

Edit: I tried this but it doesn't work.

$('.feedback').featherlight($( "#feedback-box" ), { 
    closeIcon: 'close', 
    beforeOpen: $.featherlight.close()
});
1

There are 1 answers

3
Marc-André Lafortune On BEST ANSWER

You want beforeOpen to be a function...

With the code you gave, you will get an error in the console, won't you?

You need to write instead:

// ...
beforeOpen: function() { $.featherlight.close() }