Unable to save data to database using dhtmlx scheduler, dataprocessor and angularjs

StackOverflow https://stackoverflow.com/questions/21077284

  •  27-09-2022
  •  | 
  •  

سؤال

I found in the docs dat we can send data from the scheduler to the database using this:

var dp = new dataProcessor(url)
dp.init(myobj)

EDIT I don't get an infinite loop anymore, when I put those lines of code inside the $watch-part of the code. But it still does not save anything to the DB.

myAppProfile.directive('dhxScheduler', function() {
  return {
    restrict: 'A',
    scope: false,
    transclude: true,
    template:'<div class="dhx_cal_navline" ng-transclude></div><div class="dhx_cal_header"></div><div class="dhx_cal_data"></div>',

    link:function ($scope, $element, $attrs, $controller){
      //default state of the scheduler
      if (!$scope.scheduler)
      $scope.scheduler = {};
      $scope.scheduler.mode = $scope.scheduler.mode || "month";
      $scope.scheduler.date = $scope.scheduler.date || new Date();

      //watch data collection, reload on changes
      $scope.$watch($attrs.data, function(collection){
             if(collection) {
        scheduler.clearAll();
        scheduler.parse(collection, "json");
        //this does not cause infinite loop but does not work either
        var dp = new dataProcessor("agendaController.php");
        dp.init(scheduler);
      }
      }, true);

      //watch mode and date
      $scope.$watch(function(){
        return $scope.scheduler.mode + $scope.scheduler.date.toString();
      }, function(nv, ov) {
        var mode = scheduler.getState();
        if (nv.date != mode.date || nv.mode != mode.mode)
          scheduler.setCurrentView($scope.scheduler.date, $scope.scheduler.mode);
      }, true);

      //size of scheduler
      $scope.$watch(function() {
        return $element[0].offsetWidth + "." + $element[0].offsetHeight;
      }, function() {
        scheduler.setCurrentView();
      });

      //styling for dhtmlx scheduler
      $element.addClass("dhx_cal_container");

      //init scheduler
      scheduler.config.xml_date="%Y-%m-%d %H:%i";
      scheduler.init($element[0], new Date(), "month");
      scheduler.load("agendaController.php", "json");

      //This gave infinite loop
      //var dp = new dataProcessor("agendaController.php");
      //dp.init(scheduler);
    }
  }
});

This is my controller code:

include('connections.php');
include('/db-connector/scheduler_connector.php');    

$scheduler = new JSONSchedulerConnector($conn);
$scheduler->render_table("events","id","start_date,end_date,text");

The error that I get in the console is:

RangeError: Maximum call stack size exceeded at Object.dataProcessor.init [as init_original]

can anyone help me with getting started saving events to db? Thanks!

هل كانت مفيدة؟

المحلول

I found the error, it was because I added connector.js and it is already included in dhtmlxscheduler.js. I removed this include and it started working.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top