无法使用dhtmlx调度程序,数据处理器和angularjs将数据保存到数据库

时间:2014-01-12 16:40:18

标签: angularjs dhtmlx-scheduler

我发现在docs dat中我们可以使用以下命令将数据从调度程序发送到数据库:

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

修改 当我将这些代码行放在代码的$ watch部分中时,我不再获得无限循环。但它仍然没有向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);
    }
  }
});

这是我的控制器代码:

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

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

我在控制台中收到的错误是:

  

RangeError:Object.dataProcessor.init超出了最大调用堆栈大小   [as init_original]

任何人都可以帮助我开始将事件保存到数据库吗?谢谢!

1 个答案:

答案 0 :(得分:1)

我发现了错误,这是因为我添加了connector.js,它已经包含在dhtmlxscheduler.js中。我删除了这个包含,它开始工作。