无限滚动总是拉下nextSelector网址

时间:2014-06-27 01:12:30

标签: jquery infinite-scroll

我正在寻找让infinite-scroll始终使用从" nextSelector"中检索到的网址的方法。无论网址是什么。默认情况下,它会在第一次迭代后尝试猜测网址是什么。

我试过了:

  path: function(currentPageNumber) {
    return $(".previous-issue").attr("herf");
  },
  parsePath: function(path, currentPage) {
    return $(".previous-issue").attr("herf");
  },
  pathParse: function(path, currentPage) {
    var month_string = path.replace("/blogs/mindful-matter-2014-", "");
    var month = parseInt(month_string, 10);
    var leading = (month.toString().length == 1) ? "0" + month : month;
    return ["mindful-matter-2014-" + leading];
  },

但是他们无法访问新的ajax内容。

1 个答案:

答案 0 :(得分:0)

  var data_next = $(".previous-issue").attr("href");

  var fetchDataNext = function() {
    console.log(data_next);
    return data_next;
  }

  mindful_matter.infinitescroll = function() {
    if ($('.issue-container').length == 0) return false;
    $('.issue-container').infinitescroll({
      navSelector: ".navigation",
      nextSelector: ".previous-issue",
      itemSelector: ".issue",
      extraScrollPx: 250,
      path: function() {
        return fetchDataNext();
      },
      loading: {
        finished: undefined,
        finishedMsg: "",
        img: "data:image/gif;base64,R0lGODlhAQABAHAAACH5BAUAAAAALAAAAAABAAEAAAICRAEAOw==",
        msg: null,
        msgText: "",
        selector: null,
        speed: 'fast',
        start: undefined
      }
    }, function(newElements, data, url) {

      data_next = $(newElements).attr("data-next");

      console.log(data_next);

      if ($("[data-bg-image]") == 0) return false;
      $("[data-bg-image]").each(function() {
        var $this = $(this);
        var img = $this.attr("data-bg-image");
        $this.backstretch(img);
      });
      mindful_matter.masonry();
    });
  }