How to make Vimeo Gallery work on Ajax websites

Due to the nature of Ajax websites, it is necessary to take additional steps for the plugin to work correctly there.

1. You need to activate the Ajax loading mode on the plugin's Preferences page:

2. Then add the following Javascript code to the Custom JavaScript Field on the plugin's Preferences page: 

jQuery(function($) {
    var observer;
    if (window.MutationObserver && !observer) {
        var observer = new MutationObserver(function(mutations) {
            mutations.forEach(function(m) {
                if (!m.addedNodes || !m.addedNodes.length) {
                    return;
                }
                Array.prototype.slice.call(m.addedNodes).forEach(function(el) {
                    if ($(el).find('[data-elfsight-vimeo-gallery-options]').length) {
                        jQuery('[data-elfsight-vimeo-gallery-options]').each(function(){
                            var settings = JSON.parse(decodeURIComponent(jQuery(this).attr('data-elfsight-vimeo-gallery-options')));
                            window.eappsVimeoGallery(jQuery(this), settings);
                        })
                        window.dispatchEvent(new Event('resize'));
                    }
                });
            });
        });
        observer.observe($('body').get(0), {
            childList: true,
            subtree: true
        }); 
    }
});

That's it. Now check the plugin on your website, it should work correctly.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.