将图像拖放到fullcalendar中的事件

时间:2014-01-18 23:54:43

标签: fullcalendar

我真的希望得到一些帮助。我正在为使用fullcalendar的孩子做日历。应该可以将som图标图标拖放到日历的事件中。它看起来像这样:http://boerne.migraeniker.dk/kalender_filer/default.html 但是如何显示我在活动中丢弃的图像。

应该删除图像的代码在这里:

    drop:function(start,end, allDay) {

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


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


   if (copiedEventObject.title) {


   start = $.fullCalendar.formatDate(start, "yyyy-MM-dd HH:mm:ss");



  $.ajax({
  url: 'http://boerne.migraeniker.dk/kalender_filer/add_events.php',
  data: 'title='+copiedEventObject.title+'&start='+ start +'&end='+ end,
  type: "POST",
  success: function(json) {

  }
  });



  calendar.fullCalendar('renderEvent',
  {

 title: copiedEventObject.title,
 start: start,
 end: end,
 allDay: allDay
 },
 true // make the event "stick"
 );
 }
 calendar.fullCalendar('unselect');
 }, 

我真的希望这是有道理的,否则我可以发布更多的代码。

1 个答案:

答案 0 :(得分:0)

看看External dragging demo 您需要在$('#mycalendar')中声明droppabledrop

droppable: true, // this allows things to be dropped onto the calendar !!!
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();
                }

            }

JSFiddle