Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 728
Biribu Avatar asked Dec 11 '13 15:12

Biribu


People also ask

How do you get a clicked date in FullCalendar?

Detect when the user clicks on dates or times. Give the user the ability to select multiple dates or time slots with their mouse or touch device. Allows a user to highlight multiple days or timeslots by clicking and dragging.

How do I create a dynamic event in FullCalendar?

although it is not specified on the fullcalender site, it is necessary to assign a value to the "allday" parameter to be able to add new events dynamically. If you set this value to "false", it will not add the event to the AllDay row. If you do "true" it will add to the AllDay row. Save this answer.

How do I turn off weekends in FullCalendar?

Just go from the startDate to the endDate and check if any of those days are weekends. If so, display the alert / popup and return false. select: (start, end, allDay) => { var startDate = moment(start), endDate = moment(end), date = startDate. clone(), isWeekend = false; while (date.


1 Answers

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

like image 144
msaglietto Avatar answered Sep 20 '22 14:09

msaglietto