Biribu
Biribu

Reputation: 3823

Get events clicking a day in FullCalendar

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.

Upvotes: 6

Views: 15861

Answers (1)

msaglietto
msaglietto

Reputation: 116

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

Upvotes: 9

Related Questions