Ustawiłem FullCalendar, aby akceptował kropelki, co robi. Ale obiekt przeciągany, który skonstruowałem z funkcją "cofnij", wydaje się nie rozpoznawać dat w FullCalendar jako zrzucanych i wraca z powrotem. Tu jest mój kodu:Fullcalendar: obiekt, który można przeciągnąć, odrzuca pełno-kalendarza jako droppable, mimo że fullcalendar przyjmuje kroplę
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html><head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<title>mydrag</title>
<script src="fullcalendar-bundle.js" type="text/javascript"></script>
</head><body>
<div id="mydrag" style="width: 200px; height: 100px; background-color: red;">My Drag</div>
<div id="calendar"></div>
<script type="text/javascript">
function onExternalEventDrop(date, allDay) {
alert("Dropped on " + date + " with allDay=" + allDay);
}
$('#mydrag').each(function() {
// create an Event Object (http://arshaw.com/fullcalendar/docs/event_data/Event_Object/)
// it doesn't need to have a start or end
var eventObject = {
title: 'MyDrag Title'
};
// store the Event Object in the DOM element so we can get to it later
$(this).data('eventObject', eventObject);
// make the event draggable using jQuery UI
$(this).draggable({
helper: 'clone',
//revert: 'invalid',
revert: function(droppableObj) {
//if false then no socket object drop occurred.
if(droppableObj === false) {
//revert the .myselector object by returning true
alert('Not a droppable object');
return true;
}
else {
//droppableObj was returned,
//we can perform additional checks here if we like
//alert(droppableObj.attr('id')); would work fine
//return false so that the .myselector object does not revert
return false;
}
},
revertDuration: 500, // original position after the drag
start: function(e, ui) {
$(ui.helper).css('width', $(this).css('width'));
}
});
});
$('#calendar').fullCalendar({
aspectRatio: 2.25,
header: {
left: '',
center: 'title',
right: 'prev,next'
},
columnFormat: {
month: 'dddd'
},
droppable: true,
drop: onExternalEventDrop
});
</script>
</body></html>
Kiedy przeciągnąć element Draggable na kalendarzu, element powraca (sugerując, że data kalendarz nie został rozpoznany jako prawidłowy droppable) .... ale zwrotna jest spadek wywołany z oczekiwanym alertem (sugerującym, że FullCalendar uznał, że przeciągnięcie jest prawidłowe). Spodziewam się, że przeciąganie nie powinno się cofać. Czy robię lub oczekuję czegoś złego? Przeszukałem wszystko, ale nie znalazłem niczego, co mogłoby to wyjaśnić. Każda pomoc będzie bardzo ceniona.
Aktualizacja: Zapomniałem wspomnieć, co nazwałem "fullcalendar-bundle.js" to plik zawierający następujące:
- jQuery 1.5.2
- jQuery UI 01.08.11
- fullcalendar 1.5.2 plugin
Kolejna aktualizacja: Właśnie wypróbowałem wersję FullCalendar 1.5.3, ale widzę to samo zachowanie.