Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/meteor/3.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
Meteor bootstrap3相当完整的日历流星在火焰中没有反应_Meteor_Twitter Bootstrap 3_Fullcalendar - Fatal编程技术网

Meteor bootstrap3相当完整的日历流星在火焰中没有反应

Meteor bootstrap3相当完整的日历流星在火焰中没有反应,meteor,twitter-bootstrap-3,fullcalendar,Meteor,Twitter Bootstrap 3,Fullcalendar,我在项目和pre blaze中使用了bootstrap3 Prey fullcalendar,当我更改事件的某些属性(如颜色)时,它立即反映在日历上的显示中。现在,当我更改属性时,我必须手动重新加载日历以显示更改 我在模板呈现函数中将日历实例化为 Template.packLayout.rendered = function(){ $('#calendar').fullCalendar({ //dayClick:function( date, allDay, jsEvent, v

我在项目和pre blaze中使用了bootstrap3 Prey fullcalendar,当我更改事件的某些属性(如颜色)时,它立即反映在日历上的显示中。现在,当我更改属性时,我必须手动重新加载日历以显示更改

我在模板呈现函数中将日历实例化为

Template.packLayout.rendered = function(){
  $('#calendar').fullCalendar({
      //dayClick:function( date, allDay, jsEvent, view ) {
      //  Requests.insert({title:'Request',start:date,end:date,color:'red',className:'todo'});
      //  Session.set('lastMod',new Date());
      //},
      eventClick:function(reqEvent,jsEvent,view){
        Session.set('editingReqEvent',reqEvent.id);
        Session.set('showEditEvent',true);
      },
      eventDrop:function(reqEvent){
        Requests.update(reqEvent.id, {$set: {start:reqEvent.start,end:reqEvent.end}});
        Session.set('lastMod',new Date());
      },
      events: function(start, end, callback) {
        var events = [];
        reqEvents = Requests.find();
        reqEvents.forEach(function(evt){
          event = {id:evt._id,title:evt.title,start:evt.start,end:evt.end,color:evt.color};
          events.push(event);
        })
        callback(events);
      },
      editable:true,
      weekMode: 'liquid'
    });
}

有什么变化会导致这种情况发生吗?

以下是我如何让它工作的:

1) 按照“渲染”保留日历代码

添加自动运行:

Deps.autorun(function () {
    if (Session.equals('calendarTemplateRendered', false) ||
        !calendarSubs.ready() ||
        typeof Calendar === 'undefined') {
        console.log('exiting because there is no objects to process');
        return;
    }

    console.log('trying to autorun');
    var entries = Calendar.find().fetch(),
       $calendar = $('#calendar');
    $calendar.fullCalendar('removeEvents');
    $calendar.fullCalendar('addEventSource', entries);
    $calendar.fullCalendar('rerenderEvents');
}

Blaze将为您完成其余的工作-(正确地重新绘制UI)。现在,您可以根据自己的喜好修改日历订阅,它将完美地工作。

好的,问题似乎在于如何更改渲染与blaze的工作方式(仅在显示模板时调用一次)。这很酷,但我不知道如何在事件以编程方式更改(例如,颜色更改等)时重新绘制事件。我认为日历的重新渲染过去是由模板中的这行代码驱动的。如果我取消隐藏,我可以看到lastMod日期按预期更改,但是整个日历不会重新呈现。考虑到这一点,我将数据:function(){return findAll(reqEvents)}添加到iron router打包的模板堆栈中。现在,考虑到路由现在依赖于返回的光标,并且属性更改正在写入数据库,日历是否应该重新呈现?这里没有乐趣,因此请使用重试
Deps.autorun(function () {
    if (Session.equals('calendarTemplateRendered', false) ||
        !calendarSubs.ready() ||
        typeof Calendar === 'undefined') {
        console.log('exiting because there is no objects to process');
        return;
    }

    console.log('trying to autorun');
    var entries = Calendar.find().fetch(),
       $calendar = $('#calendar');
    $calendar.fullCalendar('removeEvents');
    $calendar.fullCalendar('addEventSource', entries);
    $calendar.fullCalendar('rerenderEvents');
}