fancybox icon indicating copy to clipboard operation
fancybox copied to clipboard

Customize when using Vue.js

Open psteh opened this issue 6 years ago • 1 comments

I am using VueJS with fancybox, everything works normally but when I try to have custom buttons, the buttons are not updated.

Anyone have idea what is going on? I am new to VueJS, so my understanding on the lifecycle is not that good.

mounted() {
        $(document).ready(function() {
            $('[data-fancybox]').fancybox({
                buttons: [
                    'thumbs',
                    'close',
                ],
            })
        })
    },

psteh avatar Mar 27 '20 20:03 psteh

Vue creates and recreates the DOM elements, that might be your problem — the element with custom settings is replaced with another. Try adding a custom attribute (.attr('x-check', true) in jquery) and inspect the element to see if it sticks.

Btw you don't need the $(document).ready( wrapper inside mounted().

tontonsb avatar Jun 06 '20 23:06 tontonsb