问题描述:

I'm using the version of the FullCalendar jQuery plugin that supports Resources.

I'm dragging in external events as per this example.

It all works very well, but I can't find a way to obtain the Resource ID that's associated with the cell (day) onto which the external event has been dropped.

I'm using the drop function below.

drop: function(date, allDay) {

// this function is called when something is dropped

// retrieve the dropped element's stored Event Object

var originalEventObject = $(this).data('eventObject');

// we need to copy it, so that multiple events

// don't have a reference to the same object

var copiedEventObject = $.extend({}, originalEventObject);

// assign it the date that was reported

copiedEventObject.start = date;

copiedEventObject.allDay = allDay;

// render the event on the calendar

// the last `true` argument determines if the event "sticks"

// (http://arshaw.com/fullcalendar/docs/event_rendering/renderEvent/)

$('#calendar').fullCalendar('renderEvent', copiedEventObject, true);

// is the "remove after drop" checkbox checked?

if ($('#drop-remove').is(':checked')) {

// if so, remove the element from the "Draggable Events" list

$(this).remove();

}

}

I'd be most grateful for any help on this one please.

网友答案:

I use also this fork of FullCalendar and it is possible to obtain Resource ID when you drop an event, like this:

drop: function(date, allDay, test3, test4, resource) {          
    var originalEventObject = $(this).data('eventObject');
    var copiedEventObject = $.extend({}, originalEventObject);
    copiedEventObject.start = date;
    copiedEventObject.allDay = allDay;
    copiedEventObject.resource = resource.id;

    $('#calendar').fullCalendar('renderEvent', copiedEventObject, true);

    if ($('#drop-remove').is(':checked')) {
        $(this).remove();
    }
}

So, you should passed parameter "resource" on "drop" function and you could obtain the resource ID by calling "resource.id".

Best regards

相关阅读:
Top