fullcalendar

fullcalendar 日历上显示event 通过ajax从后台传回的json
$('#calendar').fullCalendar({ header: { left: 'prev,next', center: 'title', right: 'today' }, lang: 'zh-cn', buttonIcons: false, // show the prev/next text selectable: true, selectHelper: true, //选中天->添加 dayClick: function (start, end) { window.location.href = "working-event.html" }, events: function(start, end, callback) { $.ajax({ type: 'get', async:false, url: 'http://localhost:8082/artifact/timesheet/queryTimesheets', dataType: 'json', success: function(doc) { let events = []; let now =''; let dateTime = ''; let end ; let timeEnd; console.log(dateTime); console.log(doc.data[0].end); for(let i=0;i<doc.data.length;i++){ now = new Date(doc.data[i].start); end = new Date(doc.data[i].end); dateTime = now.getFullYear() + "-" + (now.getMonth() + 1) + "-" + now.getDate()+ " " + now.getHours() + ":" + now.getMinutes();; timeEnd = end.getFullYear() + "-" + (end.getMonth() + 1) + "-" + end.getDate()+ " " + end.getHours() + ":" + end.getMinutes();; events.push({ title: doc.data[i].title+'hhhh', start: dateTime, end: timeEnd // color: '#FFEBAC' }); } callback(events); } }); } });


html:
 <div id="calendar"></div>

 

 

 

posted @ 2018-09-14 15:57  wsjun  阅读(373)  评论(0)    收藏  举报