I'm trying to add an onChange event to the Kendo DatePicker and noticed that there is not an easy way to go about doing this, I unfortunately.
I was able to add an override by using jQuery but I can only get this to work if I know the name of the datepicker. I'm providing an example of this below for reference.
<!-- [ begin ] invoke onChange event -->
<script type="text/javascript">
$(document).ready(function () {
function onChanger() {
alert("Change :: " + kendo.toString(this.value(), 'd')); // show the value
document.forms['submitForm'].submit(); // submit the form
}
$("#datepicker").kendoDatePicker({
change: onChanger
}
);
});
</script>
<input id="datepicker" name="datepickers" />
<!-- [ end ] invoke onChange event -->
My problem is I'm looping through items which dynamically are building these datepickers.
So my code looks like this:
<code>
@(Html.Kendo()
.DatePicker()
.Name("AllTeachersObjectives_" + rec.CalendarGroupID)
.Value(rec.AllTeachersObjectives)
.Max(DateTime.Now.AddYears(10))
.Events(e => e.Change("startChange"))
)
</code>
How can I dynamically invoke the onChange event from using a name of a datePicker that is dynamic?
Any help would be greatly appreciated!!
TIA
- Dave