abletech / fullcalendar

Full-sized drag & drop event calendar (jQuery plugin)
http://arshaw.com/fullcalendar/
MIT License
23 stars 13 forks source link

revertFunc does not revert to previous resource. #16

Open jmarquesh opened 11 years ago

jmarquesh commented 11 years ago

When dropping an event in a new resource, if you call revertFunc to revert the changes, it will revert only the date and time, not the resource.

ahmad19 commented 10 years ago

@jmarquesh Did you find the solution for it?

jmarquesh commented 10 years ago

I may have a solution. I will have to check tonight.

jmarquesh commented 10 years ago

Search for this:

eventElement.draggable({

Inside that object search for this line:

stop: function(ev, ui) {

Inside that function search for this:

// resource changed?

Below that comment modify the existent code to match this:

var oldResourceId;

if (event.resource) {
    oldResourceId = event.resource.id;
    var newColumn = event.resource._col + columnDelta;
    var resources = calendar.getResources();
    event.resource = resources[newColumn];
    event.resource._col = newColumn;
}

eventDrop(this, event, dayDelta, minuteDelta, allDay, ev, ui, oldResourceId);

Search for the function eventDrop, add the oldResourceId parameter:

function eventDrop(e, event, dayDelta, minuteDelta, allDay, ev, ui, oldResourceId)

In the same function call moveEvents sending the oldResourceId:

moveEvents(eventsByID[eventId], -dayDelta, -minuteDelta, oldAllDay, oldResourceId);

Add the oldResourceId parameter to moveEvents:

function moveEvents(events, dayDelta, minuteDelta, allDay, oldResourceId)

Add these lines before the call to normalizeEvents:

if (oldResourceId !== undefined)
  e.resourceId = oldResourceId;

normalizeEvent(e, options);

Write again if you have questions.

ahmad19 commented 10 years ago

Hey i ve tried your code, but it didnt work. May be we have different versions. I ve tried this calendar and followed these steps but no luck http://www.ikelin.com/fullcalendar-resource-day-view-bug/