简体   繁体   中英

Ajax and Fancybox

I'm using an Ajaxify plugin with Wordpress and I'm trying to get fancybox (or any lightbox script!) to load when an image is clicked. The fancybox plugin works fine without using the Ajaxify plugin but doesn't load at all with the Ajaxify plugin enabled. I'm guessing I've got to somehow recall the script but I'm not too sure how to go about this. I did try to add a 'no-axify' class to the fancybox link but to no avail:

jQuery('.fancybox').each(function(){
    jQuery(this).addClass('no-ajaxy');
});

I even purchased the Pro version which is less functional than the free version and the support hasn;t helped either.

Any ideas will be much appreciated!

in the function.php, add this code: (make sure the action priority should be less than 10. I used 9.)

add_action('wp_enqueue_scripts', 'my_test_function', 9);
function my_test_function(){
    wp_enqueue_script( 'my-script', get_template_directory_uri() . '/js/mine.js', array( 'jquery' ));
}

the /js/mine.js has simple code.

jQuery(document).ready(function($) {
    $('.fancybox').addClass('no-ajaxy');
});

so, once you view source of your site, the mine.js should be included before the ajaxify.js

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM