nicolafranchini/VenoBox

automatic popup on page load

Closed this issue · 2 comments

Thanks for this amazing plugin. I would like to show a banner automatically on page load and tried the following code.

<a id="my-video-popup" href="http://vimeo.com/x">Vimeo</a>
<script>
  new VenoBox({
    selector: '#my-video-popup',
    popup: true
});
</script>

it shows error

venobox.js:961 Uncaught TypeError: Cannot set properties of null (setting 'settings')
    at init (venobox.js:961)
    at new VenoBox (venobox.js:981)
    at (index):64

Wonder if you could share a working demo to show a video, image or just HTML content in popup on page load.

Thanks.

Hi, and thank you. You missed the data attribute vbtype to your link, and the popup option should be a selector.

<a id="my-video-popup" data-vbtype="video" href="http://vimeo.com/x">Vimeo</a>

<script>
new VenoBox({
    selector: '#my-video-popup',
    popup: '#my-video-popup'
});
</script>

The first selector option can also be a class, so you can initialize all the links with the same class. The popup selector is better as ID, otherwise it would open the first element corresponding to that selector found in page.
If still having problems please publish a codepen or a jsfiddle to test.

Hi, thank you for such a quick reply. Just fixed it and it is working now. It is a request to add a code/demo for this on the site. It will help for new users.

Thank you so much.