How to get current date from kendoDatePicker not in the 'change' handler

Alexey Strakh picture Alexey Strakh · Apr 4, 2014 · Viewed 8.2k times · Source

Those approaches don't work:

dateSelectedFrom = $("#datepickerFrom").value - undefined
dateSelectedFrom = $("#datepickerFrom").value() - object has no method value()

I know that I can use this.value() and it is works fine, but the method onDateSelectedFromCalendar is used by a different dateTimePicker control (I have several on the page)

<input id="datepickerFrom" value="10/10/2011" />

   $("#datepickerFrom").kendoDatePicker({
            change: onDateSelectedFromCalendar
        });

   function onDateSelectedFromCalendar(e) {
        dateSelectedFrom = $("#datepickerFrom").value;
    }

Documentation doesn't specify any other options http://docs.telerik.com/kendo-ui/api/web/datepicker

Answer

jwatts1980 picture jwatts1980 · Apr 4, 2014

With the Kendo object you have to use data like:

var d = $("#datepickerFrom").data("kendoDateTimePicker").value();

See the documentation here.