I have a situation where several featherlight.js lightboxes (https://github.com/noelboss/featherlight) are open at the same time. I want that when one is closed, the rest are all closed as well. I tried something like this on the parent page:
$.extend($.featherlight.defaults, {
openSpeed: 1000,
afterClose: $.featherlight.close()
});
which doesn't work. From what I could gather afterClose is called after any lightbox is closed so I thought that setting might close the others... I'm really not good with javascript, does anyone have some simple way to do this?
Edit: I've included snippets of code that recreates my process below. I'm working with Wordpress so some of the links are using PHP etc.
Include featherlight:
<script src="<?php bloginfo('template_url'); ?>/featherlight/featherlight.min.js" type="text/javascript" charset="utf-8">
</script>
Each one of my custom wordpress post types is opened in a lightbox:
<div class="grid2By1" style="background-image: url('<?php the_post_thumbnail_url(); ?>');">
<a href="#" data-featherlight="<?php the_permalink(); ?>">
<p><?php the_title() ;?></p>
</a>
</div>
Then inside each post (so effectively in the new lightbox's content), there is this code, which gets the url of the next post and makes a link so that the next post can be opened in a lightbox
<?php $next = get_permalink(get_adjacent_post(false,'',true)); ?>
<a href="#" data-featherlight="<?php echo $next; ?>">NEXT</a>
This means that after clicking next a few times there are several windows open (the user can only see the latest one until he/she closes it, then they can see the one before etc), which is why I wanted them all to close when the first one is closed.
Initially I did try and close a window before another opened which would be a nicer solution but struggled a lot with how that would potentially work, and I thought this way might be easier!