Drogon
Drogon

Reputation: 360

Getting resource id by dropping external events

I am having trouble with full calendar. I have 3 resources and some external events. When I drop an external event I want to have the resource id from which I dropped my event.

But when I do this:

drop: function(date, allDay, resource) { 

    var originalEventObject = $(this).data('eventObject');
    var cObj = $.extend({}, originalEventObject);
    var resource = cObj.resource.id;
    console.log(resource + '<---- RESOURCE');

I get "undefined" back in my console.

Do I have to define resource id in the eventObject? And yes, how?

Are people here who knows a solution for this? Thanks!

Upvotes: 0

Views: 689

Answers (1)

ZheMann
ZheMann

Reputation: 91

drop: function (date, allDay, ev, ui, res) {
    var originalEventObject = $(this).data('eventObject');

    var resource = res; 
    console.log(resource);
}

Variable 'res' is the resource where to your event has been dragged. Use 'console.log(resource)' to see what attributes the resource has. (resource.id or resource.Id for example)

Note: It's important to use all the 5 params in the drop function!

Upvotes: 1

Related Questions