在fullCalendar的dayClick
FullCalendar顯示事件被定義。上dayClick
我想在用戶點擊某一天時訪問事件的數據。在dayClick中合併eventClick函數以便當我點擊特定日期時,我可以獲得特定日期發生的所有事件的事件標題,開始時間和結束時間。
在fullCalendar的dayClick
FullCalendar顯示事件被定義。上dayClick
我想在用戶點擊某一天時訪問事件的數據。在dayClick中合併eventClick函數以便當我點擊特定日期時,我可以獲得特定日期發生的所有事件的事件標題,開始時間和結束時間。
我希望這可以幫助您
$('#calendar').fullCalendar({
dayClick: function(date, allDay, jsEvent, view) {
var startDate = new Date(date.getFullYear(), date.getMonth(), date.getDay(), 0, 0, 0).getTime();
var endDate = new Date(date.getFullYear(), date.getMonth(), date.getDay(), 23, 59, 59).getTime();
var cache = new Date().getTime();
$.getJSON("/json-events.php?start="+startDate+"&end="+endDate+"&_="+cache,
function(data) {
// do stuff with the JSOn data
}
}
});
我不知道這將如何幫助。我已經有一些特定事件的日曆。當我點擊某一天(當天發生的所有事件的標題)時,我只想顯示事件的標題。此外,您的代碼不起作用。 – xan
爲什麼不呢?我認爲是在這裏問同樣的問題:http://stackoverflow.com/questions/2516050/in-the-fullcalendar-dayclick-event-can-i-get-the-events-that-already-exist-in-c – user2183923
你可以試試這個:
eventClick: function(xEvent, jsEvent, view) {
alert("Title: " + xEvent.title //Get the event title
+ "\n StartTime: " + xEvent.start //Get the event start date
+ "\n EndTime: " + xEvent.end //Get the event end date
);
console.log(xEvent); //See your console for all event properties/objects
}
xEvent
性能/對象名單。
dayClick: function(date, allDay, jsEvent, view) {
var startDate = new Date(date.getFullYear(), date.getMonth(), date.getDay(), 0, 0, 0).getTime();
var endDate = new Date(date.getFullYear(), date.getMonth(), date.getDay(), 23, 59, 59).getTime();
var cache = new Date().getTime();
$.getJSON("/json-events.php?start="+startDate+"&end="+endDate+"&_="+cache,
function(data) {
// do stuff with the JSOn data
});
alert('ENTROU!');
},
現在的作品
它會打開一個警告,你就必須把信息通緝。
我認爲這就是你要找的。
dayClick: function(date, allDay, jsEvent, view) {
var date2 = new Date(date.getFullYear(), date.getMonth(), date.getDate()+1);
//This gives the next day of the clicked day('date' contains the clicked day)
var todaysEvents = $('#calendar').fullCalendar('clientEvents', function(event) {
// Below statement returns the EVENT OBJECT of the clicked day after comparing the two dates
return event.start >= date && event.start < date2;
});
// You can now access the returned object & extract what you want
// console.log(todaysEvents); --> returns the complete object
// console.log(todaysEvents[0].title); --> returns that day's event title
},
我希望這有助於。
如果一天不包含任何事件會怎麼樣? –
@RahilWazir:在這種情況下,我想它會給一個'null'。我的意思是,假設我們將事件存儲在一個數組中,那麼該數組將爲null。 – xan
那你爲什麼不使用[eventClick](http://arshaw.com/fullcalendar/docs/mouse/eventClick/) –