dsnhalq37505 2013-05-08 06:03
浏览 36
已采纳

ajax调用的递归过多

I am usining masonry view to display content with infinite scrolling functionality. Masonry view part is working fine. For infinite scroll I have tried infinitescroll js or on the basis of scroll as I have written below code.

Problem :- After first scroll I am facing too much recursion problem.

jQuery(document).ready(function($) {
    var $container = jQuery('.main_container');
    $container.imagesLoaded(function(){
      // options
      $container.masonry({
        itemSelector: '.pin',
        isAnimated: true,
        isFitWidth: true,
        isAnimatedFromBottom: true
      });
    });

    //for infinite scrollings
    jQuery(window).scroll(function() {
        if(jQuery(window).scrollTop() + jQuery(window).height() == jQuery(document).height()) {
        alert("bottom!");
        ajaxurl = "script url here";
        var data = {start:startLimit,end:endLimit};
        jQuery.get(ajaxurl, data, function(response) {
             var $boxes = $(response);
             $('.main_container').append( $boxes ).masonry( 'appended', $boxes );
        });
        }
    });
});

I am trying this on wordpress admin section plugin.

  • 写回答

1条回答 默认 最新

  • dougui2254 2013-05-08 08:51
    关注

    After step-by-step checking I found solution , Cause of the problem I am using animate effect in masonry which is conflict some how with wordpress plugin view js.

     $container.imagesLoaded(function(){
      // options
      $container.masonry({
        itemSelector: '.pin',
        isAnimated: false,
        isFitWidth: true,
        isAnimatedFromBottom: false
      });
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?