2014-01-18 410 views
0

我真的希望得到一些幫助。我正在爲使用fullcalendar的孩子做日曆。應該可以將som圖標拖放到日曆的事件中。它看起來有點像這樣: 但是我怎樣才能顯示我放入事件的圖像。將圖像拖放到fullcalendar中的事件

應該放下圖像的代碼是在這裏:

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'); 
}, 

我真的希望這是有道理的,否則我可以發佈更多的代碼。

+0

什麼是你遇到的麻煩?每次發佈問題時,都應該儘可能多地添加詳細信息,包括結果和應該是什麼。 – nKn

+0

對不起,我是這個論壇的新手。 –

回答

0

看看External dragging demo 需要聲明droppabledrop在$( '#mycalendar')

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

相關問題