aitchkhan
aitchkhan

Reputation: 1952

fullcalendar- only get the selected event by user

Is there any possibility of only getting the selected event by user click and not the events already populated in fullcalendar? I looked into documentations but couldn't find much help there.

Though, I understand I can get all events by:

$("#calendar").fullCalendar( 'clientEvents' [, idOrFilter ] ) -> Array

But I don't want this. And I am of-course using select.

The other notable thing here is I want this value in another JS file. so,

eventClick: function (selectedEvent) {
            //selectedEvent.id
            //selectedEvent.
}

won't actually work for my case.

Here's how my config of fullCalendar looks like:

$("#calendar").fullCalendar({
        weekends: false,
        defaultView: 'agendaWeek',
        slotDuration: '00:30', // hours/minutes
        allDaySlot: false, 
        header: {
             left:   'today prev,next',
            center: 'title',
            right:  ''
        },
        height: "auto",
        contentHeight: 600,
        events: [
            {
                title  : 'event1',
                start  : '2017-05-01T12:30:00'
            },
            {
                title  : 'event2',
                start  : '2017-05-09T12:30:00',
                end    : '2010-05-09T13:30:00'
            },
            {
                title  : 'event3',
                start  : '2010-01-09T12:30:00',
                allDay : false // will make the time show
            }
        ],
        businessHours: [ // specify an array instead
            {
                dow: [ 1, 2, 3 ], // Monday, Tuesday, Wednesday
                start: '08:00', // 8am
                end: '18:00' // 6pm
            },
            {
                dow: [ 4, 5 ], // Thursday, Friday
                start: '10:00', // 10am
                end: '16:00' // 4pm
            }
        ],
        dayRender: function( date, cell ) { 
            alert('Clicked on: ' + date);

            alert('Coordinates: ' + cell);

            // alert('Current view: ' + view.name);

        },
        selectable: true,
        selectConstraint: "businessHours",
        select: function() { ... },

    })

Upvotes: 0

Views: 2101

Answers (1)

Tiago Ávila
Tiago Ávila

Reputation: 2867

Try to use eventClick:

eventClick: function (selectedEvent) {
            //selectedEvent.id
            //selectedEvent.title
        }

Upvotes: 2

Related Questions