-1

Hi everyone i am using this extension in my project and i am having problem with the ajaxEvents,i want to know what is wrong i am doing here?? Here is my code of view file and controller action

<div class="container">
    <div class="row">
        <div class="col-lg-6 col-md-6 col-sm-6 col-xs-12">
    <?= yii2fullcalendar::widget([
        'events' => $events,
        'options' => [
            'language' => 'en',
            'eventLimit' => 2,
        ],
        'ajaxEvents' => \yii\helpers\Url::to(['/jsoncalendar'])
    ]);
    ?>
        </div>
    </div>

</div>

And here is the controller code

 public function actionJsoncalendar($start=NULL,$end=NULL,$_=NULL){

    \Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;

    $times = Event::find()->where(1)->all();

    $events = array();

    foreach ($times AS $time){
        //Testing
        $Event = new \yii2fullcalendar\models\Event();
        $Event->id = $time->id;
        $Event->title = $time->title;
        $Event->start = $time->start_time;
        $Event->end = $time->end_time;
        $events[] = $Event;
    }

    return $events;
}

Tried using eventLimit as well but thats not working either

Mike Ross
  • 2,753
  • 3
  • 38
  • 81
  • Please provide link to extension that you are using. – arogachev Nov 26 '15 at 03:38
  • @arogachev added the link – Mike Ross Nov 26 '15 at 03:44
  • In `ajaxEvents` you specified url containing only action name, have you tried to specify it like with controller / module id like mentioned in the README: `'ajaxEvents' => Url::to(['/timetrack/default/jsoncalendar'])`? – arogachev Nov 26 '15 at 04:09
  • @arogachev yes i have and still giving error. I dropped using that widget anyway because it has many other issues and its github is also not updating the version. Thank you for your help anyway – Mike Ross Nov 26 '15 at 04:12
  • Maybe it's in initial stage of development. – arogachev Nov 26 '15 at 04:35

1 Answers1

1

I am using the same extension and I found out (at least in my project) that ajaxEvents should return a encoded JSON array. Try to return:

return json_encode($events);

And delete this line:

\Yii::$app->response->format = \yii\web\Response::FORMAT_JSON;