Fullcalendar 将函数名作为eventMouseover回调传递
我试图将函数的实际名称而不是匿名函数传递给FullCalendar初始化,如下所示:Fullcalendar 将函数名作为eventMouseover回调传递,fullcalendar,Fullcalendar,我试图将函数的实际名称而不是匿名函数传递给FullCalendar初始化,如下所示: $('#gcally_calendar').fullCalendar({ "eventSources": [...], "eventMouseover":"fc_hover_in" }); 但是,在执行此操作时,我遇到了一个控制台错误:uncaughttypeerror:Array.prototype.slice.call不是函数 有什么想法吗 对于彻底性,这是功能:
$('#gcally_calendar').fullCalendar({
"eventSources":
[...],
"eventMouseover":"fc_hover_in"
});
但是,在执行此操作时,我遇到了一个控制台错误:uncaughttypeerror:Array.prototype.slice.call不是函数
有什么想法吗
对于彻底性,这是功能:
function fc_hover_in(calEvent, jsEvent, view) {
var tooltip = '<div class="tooltipevent" style="width:100px;height:100px;background:#ccc;position:absolute;z-index:10001;">' + calEvent.title + '</div>';
jQuery("body").append(tooltip);
jQuery(this).mouseover(function(e) {
$(this).css('z-index', 10000);
$('.tooltipevent').fadeIn('500');
$('.tooltipevent').fadeTo('10', 1.9);
}).mousemove(function(e) {
$('.tooltipevent').css('top', e.pageY + 10);
$('.tooltipevent').css('left', e.pageX + 20);
});
}
函数fc\u hover\u in(calEvent、jsEvent、view){
变量工具提示=“”+calEvent.title+“”;
jQuery(“body”).append(工具提示);
jQuery(this).mouseover(函数(e){
$(this.css('z-index',10000);
$('.tooltipevent').fadeIn('500');
$('tooltipevent').fadeTo('10',1.9);
}).mousemove(函数(e){
$('.tooltipevent').css('top',e.pageY+10);
$('.tooltipevent').css('left',e.pageX+20);
});
}
但此时甚至没有调用它。您应该删除引号以将函数作为引用传递。
这: 变成这样:
"eventMouseover": fc_hover_in
正如下面A1rpun的答案所指出的,您可能不希望使用函数名,而是希望使用指向该函数的指针,因此您需要删除它周围的引号,否则您只是传递一个字符串。。。
"eventMouseover": fc_hover_in