• Resolved broncom

    (@broncom)


    Hello, thanks for the plugin, please tell me, can i use callback like this?

    $(“.fancybox”).fancybox({
    afterShow: function(){
    // fancybox is open, run myFunct()
    },
    afterClose: function(){
    // fancybox is closed, run myOtherFunct()
    }
    });

Viewing 4 replies - 1 through 4 (of 4 total)
  • Hi, the script version in this plugin is based on the classic FancyBox which has different callbacks. You can find them here https://fancybox.net/api … You probably need onComplete and onClosed

    Thread Starter broncom

    (@broncom)

    Thank You, but unfortunately, I can’t do it anyway)
    I have a button that opens a form and this works perfectly.

    <a href="#contact_form_pop" id="send_request" class="fancybox-inline wp-block-button__link has-white-color has-vivid-cyan-blue-background-color has-text-color has-background">Send Request</a>

    For her, I use this code and it does not work, please tell me what I am doing wrong

    $(".fancybox-inline").fancybox({
        openEffect	: 'elastic',
        closeEffect	: 'elastic',
    	width		: '70%',
       onComplete: function(){
    	   console.log('open');
       }
    });

    There are a few things you need to take into account:
    1. the plugin will “overwrite” your javascript when it gets inserted before the footer
    2. JQuery is in noconflict mode so $(…) needs to be jQuery(…) in your script snippet

    Point two is easily fixed. Point one might be worked around in two ways:
    A. Remove the fancybox-inline class from the button (so the plugin will not bind Fancybox to it automatically) AND adapt your script snippet to use the ID like jQuery("#send_request2") or another custom class.
    B. EITHER insert the code at a very late point in the wp_footer call OR move the plugin script to the header (there is an option for this in the Compatibility section on Settings > Media)

    Thread Starter broncom

    (@broncom)

    Thank you very much for your help,

    1. the plugin will “overwrite” your javascript …
    Remove the fancybox-inline class …
    AND adapt your script snippet to use the ID …

    Thats it) Now all work.

    All the best @ravanh !

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘callbacks’ is closed to new replies.