我正在使用FullCalendar和Scheduler - 从日历中删除事件时我将它们添加回外部事件div中 - 但我需要重新初始化下面的.each函数
$('#external-events .fc-event').each(function() {
// store data so the calendar knows to render an event upon drop
$(this).data('event', {
title: $.trim($(this).text()), // use the element's text as the event title
stick: true, // maintain when user navigates (see docs on the renderEvent method)
id: $(this).attr('id'),
overlap: false
});
// make the event draggable using jQuery UI
$(this).draggable({
zIndex: 999,
revert: true, // will cause the event to go back to its
revertDuration: 0 // original position after the drag
});
});
显然,我可以在.dialog上的一个按钮函数中抛出相同的函数,以确认删除事件,但我不想复制代码。
我正在尝试这样的事情而没有运气。
function externalEvents() {
// store data so the calendar knows to render an event upon drop
$(this).data('event', {
title: $.trim($(this).text()), // use the element's text as the event title
stick: true, // maintain when user navigates (see docs on the renderEvent method)
id: $(this).attr('id'),
overlap: false
});
// make the event draggable using jQuery UI
$(this).draggable({
zIndex: 999,
revert: true, // will cause the event to go back to its
revertDuration: 0 // original position after the drag
});
}
$('#external-events .fc-event').each(externalEvents());
我的思维过程是我可以运行
$('#external-events .fc-event').each(externalEvents());
每当向外部事件div添加更多元素时。
这会引发错误TypeError: invalid 'in' operand a
答案 0 :(得分:0)
如果您有括号,则在调用PHPMyAdmin
。您希望将其作为函数引用传递给externalEvents
。
each