gpt4 book ai didi

javascript - View 更改时的全日历渲染事件

转载 作者:行者123 更新时间:2023-11-29 21:55:29 25 4
gpt4 key购买 nike

我有这个代码

$('#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');
}

}
},
});

此代码的问题在于它会继续调用 eventRender,即使我已经在 agendaDay View 中也是如此。我怎样才能防止这种情况发生?

最佳答案

不确定您为什么要这样做,但这是一个有效的示例:

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;
}
})(),

请注意,这将在您每次进入 agendaDay 时再次添加该事件(不过这很容易补救)。如果您描述了您实际想要做的事情,那么可能有更好的解决方案。

关于javascript - View 更改时的全日历渲染事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26626509/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com