Question

Hi I am trying to use drag and drop external events for fullcalendar and get working with the yii extension full calender - which seems to be just a wrapper.

The part that is not working (no errors just does not work) is dragging the external event onto the calendar and it staying there. It drags over but it just returns home.

Reading the fullcalendar docs - it looks like I need to provide a callback function to 'drop' attribute. I've been using the external-event example which is part of full calendar. I did discover the example was using the object name '#calendar' and that yii is creating name '#yw0' but it still didn't work after I updated.

I cannot find a way to get it work. I tried a simple alert which sort of works, it is called on page load - not after a drag operation.

So I declared a variable with the function in View

//$dropcallback=new CJavaScriptExpression("alert('hi')");
$dropcallback=new CJavaScriptExpression(
     "function(date, allDay) {
        var originalEventObject = $(this).data('eventObject');
        var copiedEventObject = $.extend({}, originalEventObject);
        copiedEventObject.start = date;
        copiedEventObject.allDay = allDay;
        $('#yw0').fullCalendar('renderEvent', copiedEventObject, true);
        if ($('#drop-remove').is(':checked')) {
           // if so, remove the element from the Draggable Events list
           $(this).remove();
        }
     }
  ");

Then I create the widgit like this

$this->widget('ext.EFullCalendar.EFullCalendar', array(
'themeCssFile'=>'cupertino/jquery-ui.min.css',
'options'=>array(
    'header'=>array(
        'left'=>'prev,next',
        'center'=>'title',
        'right'=>'today'
    ),
    'editable'=>true,
    'dropable'=>true,
    'drop'=>$dropcallback,
    'events'=>Game::model()->gameCalendarData(),
)));

My yii experiance is little and same with JS - so any help appreciated in how to get this working.

I understand that in JS you need to provide a callback to allow the drag op to succeed. But what sort of call back do I need when it is wrapped in a yii widgit? I tried a PHP callback and again it is only called on page load.

The result I wish is that I can build the external events list from the DB - allow users to drag them onto the calendar - and save them in the DB.

I did manage to get data from DB displayed in the calendar.

Thanks

Was it helpful?

Solution

Droppable is spelt with two p's. So

'dropable'=>true,

Should be

'droppable'=>true,
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top