Capturing the hours in the fullCalendar library

0

Good morning!

I'm working with the fullCalendar library, and would like help in capturing the hours when I clicked on a particular range.

I'm getting the good date, the problem is only with the hours.

dayClick: function(start, end, allDay) {
   start = $.fullCalendar.formatRange(start, start, 'YYYY-MM-DD');
},

Thanks in advance for your attention!

    
asked by anonymous 29.11.2016 / 13:18

1 answer

2

Hello, how are you?

First of all, the 'dayClick' event is triggered when a calendar date is clicked and not a calendar event.

Another thing I noticed is that the method parameters are very different from the documentation parameters. Note: link

If your problem is an event use the 'eventClick' method. Follow the link documentation link

Here's an example of how you can do using both the triggered event by clicking a calendar day and the triggered event by clicking a calendar event.

        $('#calendar-container').fullCalendar({
        header: {
            left: 'prev, next today',
            center: 'title',
            right: 'month, basicWeek, basicDay'
        },
        locale: 'pt-br',
        defaultDate: '2016-12-19',
        navLinks: true,
        editable: false,
        eventLimit: true, 
        events: events,
        dayClick: function(date, jsEvent, view){
            console.log("Clicou no dia: " + date.format());
        },
        eventClick: function(calEvent, jsEvent, view){
            console.log("Clicou no evento: " + calEvent.title);

            // Marco o evento clicado
            $(this).css('border-color', 'red');

            if(calEvent.url){
                // Ativar um modal aqui

                // Cancelo o evento
                return false;
            }
        }
    });
    
19.12.2016 / 14:56