Capture the hours in the fullCalendar library

Asked

Viewed 415 times

0

good morning!

I am working with the library fullCalendar, and would like help in capturing the hours when clicked on a certain interval.

I’m getting a lot of good, the problem is only with the hours.

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

From now on, thank you for your attention!

1 answer

2

Hello, all right?

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

Another thing I realized is that the method parameters are quite different from the documentation parameters. Note: https://fullcalendar.io/docs/mouse/dayClick/

If your problem is an event use the 'eventClick' method. Follow the documentation link https://fullcalendar.io/docs/mouse/eventClick/

Here’s an example of how you can do using both the Shot Event by clicking on a calendar day and the Shot Event by clicking on 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;
            }
        }
    });
  • Welcome to the stackoverlow community. While this link may answer the question, it is best to include the essential parts of the answer here and provide the link for reference. For example, how to implement this.

  • I improved my answer.

  • Now yes good answer, +1

Browser other questions tagged

You are not signed in. Login or sign up in order to post.