lorenos
lorenos

Reputation: 99

How to add events in fullcalendar with scheduler.js?

I don't know how to add events in fullcalendar scheduler.js, can anyone help me?

I can add events with fullcalendar but without scheduler.js that works.

When I add this code to my script the event won't add

select: function(start, end) 
{
    this.title = prompt('Event Title:');
    this.eventData;
    if (this.title) {
        this.eventData = {
            title: this.title,
            start: start,
            end: end
        };
        $('#calendar').fullCalendar('renderEvent', this.eventData, true); // stick? = true
    }
    $('#calendar').fullCalendar('unselect');
},

Upvotes: 1

Views: 3130

Answers (1)

Saurav Dangol
Saurav Dangol

Reputation: 904

You need to load resource and specify your resource ID in your event as well. So if you put these it will work out. Try this code.

 select: function(start, end) 
    {
        this.title = prompt('Event Title:');
        this.eventData;
        if (this.title) {
            this.eventData = {
                title: this.title,
                start: start,
                end: end,
                resourceId:['ResourceID1'] // Example  of resource ID
            };
            $('#calendar').fullCalendar('getResources')// This loads the resources your events are associated with(you have toload your resources as well )
            $('#calendar').fullCalendar('renderEvent', this.eventData, true); // stick? = true
        }
        $('#calendar').fullCalendar('unselect');
    },

Resource example is as follows:

$('#calendar').fullCalendar({
header: {left: 'prev,next today', center: 'title', right: ''},
                    selectable: true,
allDayDefault: false,
unselectAuto: false,
editable: false,
slotLabelFormat:"HH:mm",
resources: [[id:'ResourceID1', title:"Just a title"],[id:'ResourceID2', title:"Just a title part II"]]
})

Upvotes: 1

Related Questions