Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript “添加到愿望列表”按钮在漂亮的照片脚本中不起作用_Javascript_Jquery_Prettyphoto - Fatal编程技术网

Javascript “添加到愿望列表”按钮在漂亮的照片脚本中不起作用

Javascript “添加到愿望列表”按钮在漂亮的照片脚本中不起作用,javascript,jquery,prettyphoto,Javascript,Jquery,Prettyphoto,我不明白为什么我的脚本不再运行。我读过其他帖子,他们似乎只是假设jQuery没有正确加载,或者没有按照正确的顺序加载 为什么这不能按计划进行 Functions.php: function hubble_space_scripts() { wp_enqueue_script('jquery'); wp_enqueue_script('slick-scripts', get_template_directory_uri() . '/js/slick.js', array(), nu

我不明白为什么我的脚本不再运行。我读过其他帖子,他们似乎只是假设jQuery没有正确加载,或者没有按照正确的顺序加载

为什么这不能按计划进行

Functions.php:

function hubble_space_scripts() {
    wp_enqueue_script('jquery');
    wp_enqueue_script('slick-scripts', get_template_directory_uri() . '/js/slick.js', array(), null, true);

    wp_enqueue_script('hubble-space-navigation', get_template_directory_uri() . '/js/navigation.js', array(), '20151215', true);
    wp_enqueue_script('hubble-space-skip-link-focus-fix', get_template_directory_uri() . '/js/skip-link-focus-fix.js', array(), '20151215', true);
    wp_enqueue_script('pretty-photo-scripts', get_template_directory_uri() . '/js/pretty-photo.js', array(), null, true);
    wp_enqueue_script('hubble-space-theme-script', get_template_directory_uri() . '/js/hubble-space.min.js', array(), '20151215', true);
    wp_enqueue_script('ready-functions-scripts', get_template_directory_uri() . '/js/ready-functions.js' . '?' . date("ymdhis"), array(), null, true);
}
add_action('wp_enqueue_scripts', 'hubble_space_scripts');
HTML输出:

  • 为钻石选择一块板 我的材料 我的棍子 我的共聚物 我的多义词 创建一个新板 董事会名称 公开的 共享 私有的 该项目已添加!

    可在
    多种形式

  • (发布了问题作者的解决方案,将其从问题中移除)

    我一直在使用AJAX请求填充我的产品,这是在PrettyTo脚本运行之后发生的,因此我必须在新产品加载到页面后重新启用PrettyTo,如下所示:

    // REENABLE PRETTY PHOTO AFTER AJAX CALLS
    function ReenablePrettyPhoto() {
        console.log('Reenable function is running!');
    
        setTimeout(function() {
    
            console.log('Reenable function waited, and has now ran!');
    
            var prettyPhotoLinks = $("a[data-rel^='prettyPhoto']")
            if (prettyPhotoLinks.length) {
                prettyPhotoLinks.each(function(){
                    $(this).prettyPhoto();
                });
            }
    
        }, 1000);
    
    }
    // END REENABLE PRETTY PHOTO AFTER AJAX CALLS
    
    然后,我必须在每次重新加载产品时运行该函数:

    ReenablePrettyPhoto();
    

    然后,这将重新创建链接,功能将按预期返回。

    不确定,但在本文中,它们将插入覆盖,如果未定义,可能是您使用了它们的脚本@bestinamir-我无法使用此资源解决问题。也许你可以看看我正在玩的实时版本:(点击产品上的加号-它不会在漂亮的照片中弹出)。