Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Handle dblclick in Fullcalendar jQuery plugin

I know that this question has been asked before, but several new versions have been released since then.

Is it possible to handle a dblclick event for creating a new appointment in the calendar without having to modify the fullcalendar.js file? It would be great to handle this extension in a separate file together with my other tweaks.

Thanks in advance!

/Adam

like image 989
adamfinstorp Avatar asked Nov 14 '11 16:11

adamfinstorp


People also ask

How do I select multiple dates 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 turn off past dates in Fullcalendar?

You can try the following thread's solution(dayClick or select function to disable the dayclick for the past dates in fullcalendar). You can visit the fullcalendar support center and post your fullcalendar question on the StackOverflow fullcalendar tag.

How do I change colors in Fullcalendar?

You can change the color of all events on the calendar like so: var calendar = new Calendar(calendarEl, { events: [ // my event data ], eventColor: '#378006' }); You can use any of the CSS color formats such #f00 , #ff0000 , rgb(255,0,0) , or red .


2 Answers

Just to add to Juan Gonzales's answer:

$("#calendar").fullCalendar({
    dayRender: function(date, element, view){
        element.bind('dblclick', function() {
            alert('double click!');
        });
    }
});

This code will create the dblclick event to the whole "day" event.

Source

like image 185
Michel Ayres Avatar answered Sep 20 '22 09:09

Michel Ayres


I ran across the same issue and didn't want to fiddle with the core, so I wrote double-click logic into the dayClick callback.

dayClick:function( date, allDay, jsEvent, view ) {
            var singleClick = date.toUTCString();

            if(doubleClick==singleClick){
                console.log('Double-click!');
                doubleClick = null;
            }else{
                doubleClick=date.toUTCString();
                clearInterval(clickTimer);
                clickTimer = setInterval(function(){
                    doubleClick = null;
                    clearInterval(clickTimer);
                }, 500);
            }
        }

clickTimer and doubleClick are declared before the call to initialize the calendar.

like image 41
Anthony Watkins Avatar answered Sep 22 '22 09:09

Anthony Watkins