When using datepicker, when I click on the "Today" button then today's date is shown in datepicker. However, when I click on the "Done" button then today's date is not displayed in the field. Currently, I have to actually click on the date (i.e., Today -> select date). I would prefer clicking Today -> Done.
How can I click on a date field, click on the "Today" button and then click on the "Done" button and to have today's date reflected in the date field?
Update:
Below is what I am experimenting with. Pardon the mess - I am new to jQuery / javascript.
$(document).ready(function () {
$(".datePicker").datepicker({
changeMonth: true,
changeYear: true,
dateFormat: "yy-mm-dd",
yearRange: 2000:c+1,
showButtonPanel: true,
@*
beforeShow: function (input, instance) {
$(input).datepicker('setDate', new Date());
}
*@
});
$('.datePicker').click(function () {
$('button.ui-datepicker-current').removeClass('ui-priority-secondary').addClass('ui-priority-primary');
});
$(document).on('click', "button.ui-datepicker-current", function () {
$(".datePicker").datepicker('setDate', new Date())
});
@* Set focus to the next datepicker. This allows the user to re-select the same date field.
Otherwise, a user must click another date field in order to be able to re-select the date field.
*@
$("body").delegate("button[data-handler=today]", "click", function () {
$("#Date").datepicker("setDate", new Date()).datepicker("hide");
$("#RDate").focus();
});
@* This does not work, but provided for ideas.
$(".datepicker").each(function () {
$(this).datepicker('setDate', $(this).val());
});
*@
});