Kartik Datepicker Eventhandling or proper way of handling date changes

Hi I’m using the kartik datepicker widget to let the user pick a date which should then be inserted into a database. Actually I wan t the picker to fire a event when the date is selected or changed. So according to the documentation of the kartik datepicker widget you can do so by using the pluginEvent section. This is my datepicker.




 <?php

                      echo DatePicker::widget([

                        'name' => 'datepicker_from',

                        'type' => 1,

                        'value' => 'vom',

                        'pluginOptions' => [

                            'format' => 'D, dd-M-yyyy',

                            'startDate' => date("dd-mm-yyyy"),

                            'autoclose' => true

                        ],

                          'options' => [

                            "id" => "news_from_date"


                        ],

                          'pluginEvents' => [

                              "onDateChange" => " alert('test')",

                          ],


                      ]); ?>

The problem is that the events triggers always at the moment of page loading and not when the date changes. So it fires once and then never again. I even tried “onSelect” without any success. I found out that it doesn’t matter what I type into the eventname part it will always trigger on page load. So instead of “onDateChange” I could wright “EverybodyLikesCheese” and it would still trigger on pageload.

I searched now for hours and couldn t find a solution to that problem. Probably I’m missing something or didn t consider. Here’s my Controller




 public function actionModule_benachrichtigungen_form()

    {

        return $this->renderAjax('modules/module_benachrichtigungen_form');

    }



I quiet new to Yii and I don’t know if renderAjax is causing those problems ? But renderPartial didn t work properly. The datepicker doesn t throw any JS Error. The view uses JS function of an custom JS file I don’t know whether this could cause problems.

I m asking myself if this is a proper way. I assume that I could create a button which then loads the date and puts it into a database or are there other ways to do it or is it just fine to do this for example onSelect ?

Thanks for your help

greetings