This question is locked. New answers and comments are not allowed.
Hello,
In my date.cshtml editor template, I have added a 'today' anchor to automatically put todays day the datepicker field. This saves a lot of time in our application.
I accomplish it like this:
My DatePickerTodayClicked looks like this:
This works great.... but when I subscribe to the OnChange client event of a datepicker in my applications, they don't get executed when the today link is clicked.
I tried calling picker.onChange(); manually, but that just results in a crash. Is there something I can do to get this working?
In my date.cshtml editor template, I have added a 'today' anchor to automatically put todays day the datepicker field. This saves a lot of time in our application.
I accomplish it like this:
@{ var datepicker = Html.Telerik().DatePicker() .Format("dd MMM yyyy") .Name(ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty)) .HtmlAttributes(new { id = ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty) + "_wrapper" }) .Value(Model);}@datepicker | <a href="#" onclick="DatePickerTodayClicked(event, @ViewData.TemplateInfo.GetFullHtmlFieldName(string.Empty)');">today</a>My DatePickerTodayClicked looks like this:
function DatePickerTodayClicked(e, datePickerId) { var id = '#' + datePickerId.replace('.', '_'); var input = $(id); if (input == null) { alert('"ERROR: input ' + id + ' not found.'); return; } var picker = input.data('tDatePicker'); if (picker == null) { alert('ERROR: date picker ' + id + ' not found.'); return; } picker.value(new Date()); e.preventDefault();}This works great.... but when I subscribe to the OnChange client event of a datepicker in my applications, they don't get executed when the today link is clicked.
I tried calling picker.onChange(); manually, but that just results in a crash. Is there something I can do to get this working?