Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Magnific-Popup, Limit items to direct siblings

How can I limit magnific-popup gallery to direct siblings? When I open an image from the first .child, I don’t want the images from the second .child to be in the gallery.

The html structure:

<div class="parent">
    <div class="child">
        <a class="image-link" href="img/red1.jpg"><img src="img/red1.jpg"></a>
        <a class="image-link" href="img/red2.jpg"><img src="img/red2.jpg"></a>
        <a class="image-link" href="img/red3.jpg"><img src="img/red3.jpg"></a>
        <a class="image-link" href="img/red4.jpg"><img src="img/red4.jpg"></a>
        <a class="image-link" href="img/red5.jpg"><img src="img/red5.jpg"></a>
    </div>

    <div class="child">
        <a class="image-link" href="img/city1.jpg"><img src="img/city1.jpg"></a>
        <a class="image-link" href="img/city2.jpg"><img src="img/city2.jpg"></a>
        <a class="image-link" href="img/city3.jpg"><img src="img/city3.jpg"></a>
        <a class="image-link" href="img/city4.jpg"><img src="img/city4.jpg"></a>
        <a class="image-link" href="img/city5.jpg"><img src="img/city5.jpg"></a>
    </div>
</div>

how I initialize Magnific-Popup:

$('.child').magnificPopup({ 
    delegate: '.image-link',
    type:'image', 
    gallery: {
        enabled: true
    }
});
like image 230
gang Avatar asked May 17 '13 07:05

gang


1 Answers

If delegate option is used, only like so:

$('.child').each(function() {
     $(this).magnificPopup({ 
        delegate: '.image-link',
        type:'image', 
        gallery: {
            enabled: true
        }
    });
});
like image 138
Dmitry Semenov Avatar answered Oct 14 '22 07:10

Dmitry Semenov