Get events clicking a day in FullCalendar

﹥>﹥吖頭↗ 提交于 2019-12-21 05:05:20

问题


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.

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:


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



来源:https://stackoverflow.com/questions/20523905/get-events-clicking-a-day-in-fullcalendar

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!