2amigos / yii2-gallery-widget

BlueImp Gallery Widget for Yii2
http://yiiwheels.com
Other
60 stars 37 forks source link

How to get the js instance of the gallery or carousel? #28

Closed almirb closed 5 years ago

almirb commented 5 years ago

Hello,

How can I get the js instance of the gallery? I want to run Blueimp API commands... I tried:

var gallery = $('#blueimp-gallery').data('gallery');

As shown at the official Blueimp Gallery docs, but that always returns undefined...

The problem:

I have an Youtube video slideshow inside a modal. When I hide the modal before pausing the video, I keep listening the audio.. I would like to stop the video when hiding the modal.

Thanks!

tonydspaniard commented 5 years ago

@almirb you need to check the id of the widget at the resulting web page. I highly recommend you to configure the widget's id so is not randomly created by Yii. That way you could then get the instance:

<?= dosamigos\gallery\Gallery::widget(['id' => 'my-gallery', 'items' => $items]);?>
var gallery = $('#my-gallery').data('gallery');

let me know if it works. br