Dropping onto an event (as opposed to the calendar) - how to identify event?

懵懂的女人 提交于 2019-12-06 11:29:38

问题


I have successfully implemented dragging of a jquery-ui element onto my fullCalendar. The problem is that what I want to drop onto is not the calendar itself but a specific event displayed on the calendar in order to add the dropped item to the event. The missing piece is how to identify the event that was under the mouse when I dropped.

drop: function (date, allDay, jsEvent, ui)
{
   var event = ???;
   event.description += ui.helper.data("filters").text;
   $('#calendar').fullCalendar('updateEvent', event);
}

回答1:


I've discovered the solution. Basically you have to add "droppable" to the event element. I do this by catching the "eventRender" (I assume this is a good spot)...

eventRender: function (event, element)
{
    // store the ID for later...
    $(element).data('id', event.id);
    element.droppable({
        drop: function (event, ui)
        {
            // get the ID I stored above...
            var rowID = $(this).data('id');



回答2:


I just implemented this - thankyou for your solution!

I'm using it in combination with drop - I need to be able to drop events either onto another event or onto a date.

In my case adding event.stopPropogation(); in element.droppable drop is necessary to stop the date drop function from also triggering.



来源:https://stackoverflow.com/questions/5833949/dropping-onto-an-event-as-opposed-to-the-calendar-how-to-identify-event

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!