Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/437.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 Meteor:如何在无限滚动页面中显示动态集合_Javascript_Meteor - Fatal编程技术网

Javascript Meteor:如何在无限滚动页面中显示动态集合

Javascript Meteor:如何在无限滚动页面中显示动态集合,javascript,meteor,Javascript,Meteor,在监控系统应用程序上, 我发布了一个庞大集合的一小部分,因为大多数时候我们只需要几个文档 在服务器上: Meteor.publish("amon", function() { return Mon.find({}, { sort: { utctime: -1 }, limit: 250 }) }) 问题是,有时我需要向下滚动页面以获得更多结果。 重新发布不起作用(错误消息:忽略名为“amon”的重复发布),

在监控系统应用程序上, 我发布了一个庞大集合的一小部分,因为大多数时候我们只需要几个文档

在服务器上:

Meteor.publish("amon", function() {
    return Mon.find({}, {
        sort: {
            utctime: -1
        },
        limit: 250
    })
})
问题是,有时我需要向下滚动页面以获得更多结果。
重新发布不起作用(错误消息:忽略名为“amon”的重复发布),实际上不是一个选项,因为它会影响所有客户端。
下面是一段代码,当我们接近页面滚动结束时检测,以触发额外数据的加载,但它始终限于250个已发布的文档

下面是一段代码,显示了如何查看显示的250个文档:

$(window).scroll(function() {
      var livehistory = Session.get('livehistory')
      if (
          (document.getElementById('tabpage_1').style.display != "none") &&
          ($(document).height() - $(document).scrollTop() <= $(window).height() + 100) &&
          (livehistory < 2000)
          )
      {
        console.log("Scrolled Down");
        livehistory = livehistory + 200
        Session.set('livehistory', livehistory)
      } 
      if ($(document).scrollTop() < $(window).height()*0.5) {
        // We're back to normal mode, so reduce displayed history and enable live mode.
        Session.set('livehistory', 80)
        Session.set('live', true)
      } else {  
        Session.set('live', false)
      } 
});
向下滚动页面时,如何显示超过250个文档?
理想情况下,通过使用“跳过”只显示(并同步)所需的数据片段来访问数百万个文档


谢谢,

您看到了吗?请签出此软件包谢谢用户728291,它看起来像是来自meteorpedia的示例正是我想要的。对于大气包,它可以做到,但首先他们需要解决反应性问题。Meteopedia的例子对我有效。我不知道我们可以通过这种方式将参数发送到发布。这就是我一直在寻找的解决方案。谢谢
Template.log.loglines = function() {
    var query = Mon.find({}, {
        sort: {
            utctime: -1
        },
        limit: Session.get('livehistory'),
        reactive: Session.get("live") || false
    })
    return query
};