javascript 获取在 FullCalendar 中单击一天的事件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/20523905/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Get events clicking a day in FullCalendar
提问by Biribu
I want to know if is possible to get a list or array or something with events of one day by clicking that day in fullcalendar.
我想知道是否可以通过在 fullcalendar 中单击那天来获取列表或数组或某天的事件。
Now I get the events from google calendar, if I need to make a query each time I want to get events of one day, it will be so hard for connections. I guess it has to be possible since you already have the events for rendering them.
现在我从谷歌日历中获取事件,如果我每次想要获取某一天的事件时都需要进行查询,那么连接将非常困难。我想它必须是可能的,因为你已经有了渲染它们的事件。
One user ask me for code:
一位用户向我索要代码:
dayClick: function(date, allDay, jsEvent, view) {
console.log(date);
console.log(allDay);
console.log(jsEvent);
console.log(view);
if (allDay) {
// alert('Clicked on the entire day: ' + jsEvent);
}
},
eventClick: function(event) {
if (event.url) {
return false;
}
}
I can't understand why someone voted me negative. I made a question, someone ask for code, I put code but I EXPLAINED why I have no more code, and -1 vote? I can't understand it.
我不明白为什么有人给我投了反对票。我提出了一个问题,有人要求提供代码,我放了代码但我解释了为什么我没有更多代码,并且 -1 票?我无法理解。
回答by msaglietto
I think you could do something like
我想你可以做类似的事情
dayClick: function(date, allDay, jsEvent, view) {
var dayEvents = $('yourSelector').fullCalendar( 'clientEvents' function(event){
return event.start.setHours(0, 0, 0, 0) === date.setHours(0, 0, 0, 0);
//or some way to compare that is the same day
//I recommend momentjs lib ex moment(event.start).isSame(date,'day')
});
}
What I suggest is to query the client events and filter it checking if its the same day
我的建议是查询客户端事件并过滤它检查它是否在同一天