2012-08-15 51 views
2

我正在使用支持资源的FullCalendar jQuery plugin版本。在删除外部事件时在FullCalendar上获取资源ID

我按照this example拖动外部事件。

这一切工作得很好,但我找不到方法来获取与外部事件已被删除的单元格(日)关联的Resource ID

我正在使用下面的拖放功能。

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(); 
    } 
} 

我非常感谢您对此问题的任何帮助。

+0

你是什么意思的'资源ID'?您是否在寻找事件发生地点的日期/时间? – ganeshk 2012-08-15 13:09:29

+0

它看起来像'eventDrop'方法中的资源对象是可用的,但我认为您需要自定义该插件以使其在'drop'中可用。 – cOle2 2012-08-15 20:13:54

+0

谢谢Ganesh。 它是一个FullCalendar版本,允许资源列在左侧 - 请参阅http://tux.fi/~jarnok/fullcalendar-resourceviews/ 每个资源都有一个ID和一个名称。 其他所有工作都正常,但当外部事件发生时,我无法获得相关资源的ID。 再次感谢。 – Nick 2012-08-15 20:59:19

回答

1

我也用FullCalendar的这把叉子,这是可能的,当你把一个事件,这样获得的资源ID:所以

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(); 
    } 
} 

,你应该通过参数“资源”上“滴”功能,您可以通过调用“resource.id”来获取资源ID。

致以问候

+0

如何将“resource”元素传递给放置函数?我在这个插件中找不到放置函数被调用的地方。 – Naelyth 2014-02-17 09:48:36

+0

这不起作用。我得到:'Uncaught TypeError:不能按预期读取undefined'的属性'id'。 – 2015-05-21 12:01:36

+0

它不起作用,你有黑客入侵的插件是注入资源数据的下拉回调? – Genjuro 2015-11-28 11:24:40