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
};