使用Meteor自动订阅时创建的多个完整日历
我正在尝试流星与fullcalendar创建一个预订系统。基于此post(),我可以使用事件集合创建和刷新fullcalendar。但奇怪的事情发生了,当我试图添加基于不同类别的事件过滤器,使用自动订阅。在DIV中会创建多个日历表。如果使用subscribe of Meteor返回所有事件,则不会发生这种情况 如何解决?非常感谢你的帮助 Meteor客户端JS代码片段如下:使用Meteor自动订阅时创建的多个完整日历,meteor,fullcalendar,Meteor,Fullcalendar,我正在尝试流星与fullcalendar创建一个预订系统。基于此post(),我可以使用事件集合创建和刷新fullcalendar。但奇怪的事情发生了,当我试图添加基于不同类别的事件过滤器,使用自动订阅。在DIV中会创建多个日历表。如果使用subscribe of Meteor返回所有事件,则不会发生这种情况 如何解决?非常感谢你的帮助 Meteor客户端JS代码片段如下: Meteor.autosubscribe(function(){ Meteor.subscribe("E
Meteor.autosubscribe(function(){
Meteor.subscribe("Events", Session.get('current_category'));
});
....
Template.doctors.rendered = function() {
....
$('#calendar').fullCalendar({
....
events: function(start, end, callback) {
var cal_events = [];
events.find().forEach(function(event_item) {
var doc_name = doctors.findOne(event_item.doctor).name;
cal_events.push({
title: doc_name,
start: event_item.start,
end: event_item.end,
allDay: false,
});
}
});
callback(cal_events);
},
....
});
....
}
解决了的 这里的主要问题是“Template.doctors.rendered”多次运行,这会生成多个完整日历实例。
我将下面的日历
移动到一个单独的模板中作为“cal_容器”,并将“template.doctors.rendered”下的所有代码移动到“template.cal_容器.rendered”中。现在它可以工作了。您想在类别更改或事件数据更改时更新日历吗?如果第一个为真,只需将订阅放入Deps.autorun()
。自动运行中的代码将在事件集合更改时重新运行,因此在此函数中,您应该将数据传递给fullCalendar函数。谢谢。我解决了这个问题,并相应地更新了帖子。