Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/446.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/81.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 Jquery函数和无限滚动元素_Javascript_Jquery_Magento - Fatal编程技术网

Javascript Jquery函数和无限滚动元素

Javascript Jquery函数和无限滚动元素,javascript,jquery,magento,Javascript,Jquery,Magento,我有一个脚本,弹出一个窗口的每一个链接与类附加 jQuery(document).ready(function() { jQuery('.product-quick-view a').magnificPopup({ type: 'ajax', midClick: true, mainClass: 'mfp-fade' }); }); 它可以很好地工作,但只适用于第一页显示的元素。当我向下滚动页面并无限滚动将下一个产品添加到页面

我有一个脚本,弹出一个窗口的每一个链接与类附加

jQuery(document).ready(function() {

    jQuery('.product-quick-view a').magnificPopup({
        type: 'ajax',
        midClick: true,
        mainClass: 'mfp-fade'
    });

});

它可以很好地工作,但只适用于第一页显示的元素。当我向下滚动页面并无限滚动将下一个产品添加到页面时,脚本将无法工作(该产品)。

我认为您需要添加以下内容:

$(document).ajaxSuccess(function(){
    jQuery('.product-quick-view a').magnificPopup({
        type: 'ajax',
        midClick: true,
        mainClass: 'mfp-fade'
    });
});

每当ajax成功完成时,就会执行上述操作。

添加新元素时,您可能应该对新元素调用.magnificpoop()函数。但它会为页面上已经存在的项目添加第二个(第三个、第四个…)处理程序。根据插件的不同,这可能会导致问题。