0

AngularJS UI-calendar doesn't update $scope.eventSources data model, after an event Drag and Drop. I need to get the updated model , and nothing works.

I 've tried plenty of things, nothing works. .

This is my code :

    /* config object */
        $scope.uiConfig = {
          calendar:{
            height: 600,
            editable: true,
            header:{
              left: 'month basicWeek basicDay agendaWeek agendaDay',
              center: 'title',
              right: 'today prev,next'
            },
            eventClick: $scope.alertEventOnClick,
            eventDrop: $scope.alertOnDrop,
            eventResize: $scope.alertOnResize,
            eventRender: function (event, element) {

                if (event.HighPriority == 1) {
                   event.className ='highPriority';
                }

            }

          }
        }; 

    /* load events source that contains custom events on the scope */
        $scope.events = agendaFactoryLocalStorage.getAgenda();

        $scope.eventSources = [$scope.events];

$scope.alertOnDrop = function(event, delta, revertFunc, jsEvent, ui, view){
   $scope.alertMessage = ('Event Droped to make dayDelta ' + delta);
    uiCalendarConfig.calendars.exampleCalendar.fullCalendar('removeEvents');
    uiCalendarConfig.calendars.myCalendar.fullCalendar('refetchEvents');
});

$scope.save_agenda = function(){
        agendaFactoryLocalStorage.updateAgenda($scope.eventSources);
}

$scope.save_agenda still send the same data model, while i 've drag and dropped 1 event , i really dont know what to do, stuck since 3 hours. $scope.eventSources loads correctly, but, drag and drops doesnt change the model, only the 'event ' variable is updated , but it is unique, i 've tried to push it inside $scope.eventSources with no luck

harmonius cool
  • 337
  • 1
  • 2
  • 23

1 Answers1

0

Well, i 've found something who will probably work , it is updating $scope.eventSources correctly now after dragging an event:

$scope.alertOnDrop = function(event, delta, revertFunc, jsEvent, ui, view){
                 $scope.alertMessage = ('Event Droped to make dayDelta ' + delta); 
                 $scope.eventSources[0][1].start = event.start.format();
    };

it is updating the old date value with the dragged date value i still have to get the correct index each times .

harmonius cool
  • 337
  • 1
  • 2
  • 23