本文介绍了查看更改时Fullcalendar呈现事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个代码

  $('#calendar')。fullCalendar({
viewRender:function元素){
if(view.name ==agendaDay){
if(jQuery(#calendar)。hasClass(hasRendered)== false){
var newEvent = {
start:'2014-10-29 07:00',
结束:'2014-10-29 10:00',
allDay:false,
};
$('#calendar')。fullCalendar('renderEvent',newEvent,'stick');
}

}
},
});

这段代码的问题在于,即使我已经在议程中,它仍会继续调用eventRender视图。我不知道为什么你想这样做,但这里有一个工作的例子:

/ p>

  viewRender:(function(){

var lastViewName;
(view.name ==='agendaDay'&&&&lastViewName!= view.name){

var newEvent =返回函数(视图,元素){

if {
start:'2014-06-12T10:30:00',
end:'2014-06-12T12:30:00',
allDay:false,
title :'我的测试会议'
};
$('#calendar')。fullCalendar('renderEvent',newEvent);
}

lastViewName = view。名称;
}
})(),

每次你去的时候都会再次发生这个事件议程日(尽管如此,这可以很容易地解决)。如果你描述你真正想做的事情,那么可能有更好的解决方案。


I have this code

$('#calendar').fullCalendar({
    viewRender:function(view,element){
        if(view.name == "agendaDay"){
            if(jQuery("#calendar").hasClass("hasRendered") == false){
                var newEvent = {
                    start: '2014-10-29 07:00',
                    end: '2014-10-29 10:00',
                    allDay: false,
                };
                $('#calendar').fullCalendar( 'renderEvent', newEvent,'stick');
            }

        }
    },
});

The problem with this code is that it keeps on calling the eventRender even if I am already in the agendaDay view. How can I prevent that one to happen?

解决方案

Not sure why you would want to do this but here's a working example:

http://jsfiddle.net/3E8nk/762/

viewRender:(function() {

    var lastViewName;
    return function(view, element) {

        if(view.name === 'agendaDay' && lastViewName != view.name) {

            var newEvent = {
                start: '2014-06-12T10:30:00',
                end: '2014-06-12T12:30:00',
                allDay: false,
                title: 'My test meeting'
            };
            $('#calendar').fullCalendar( 'renderEvent', newEvent);
        }

        lastViewName = view.name;
    }
})(),

Note that this will add the event again every time you go to agendaDay (this can easily be remedied though). If you describe what you actually want to do there's probably a better solution for all this.

这篇关于查看更改时Fullcalendar呈现事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 13:57