Mar*_*sen 1 javascript fullcalendar
我正在尝试动态地将事件添加到我的日历中
从文档中我收集了以下代码:
$.ajax({
type: 'POST',
url: '/Calendar/findEvents',
dataType: 'json',
data: {
request: 'ajax'
},
success: function (data)
{
var date = new Date();
var d = date.getDate();
var m = date.getMonth();
var y = date.getFullYear();
$('.calendar').fullCalendar( 'renderEvent', event
[{
title: 'All Day Event',
start: new Date(y, m, d)
}]
);
}
});
Run Code Online (Sandbox Code Playgroud)
然而,这似乎不起作用.
我收到以下错误:
Uncaught TypeError: Cannot read property 'source' of undefined fullcalendar.min.js: 6
Run Code Online (Sandbox Code Playgroud)
任何人都可以告诉我我错过了什么或我做错了什么,以便在我的日历中添加一个事件?
小智 6
您应该传递一个对象,并添加true以修复日历中的新事件:
var myevent = {title: 'All Day Event',start: new Date(y, m, d)};
$('.calendar').fullCalendar( 'renderEvent', myevent, true);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4927 次 |
| 最近记录: |