Reputation: 3141
I have an application where I have multiple date fields. All of these fields are datepicker.
This application also have some processes where it updates automaticly the value of these fields using
$('#selector').datepicker('setDate', aDate);
The problem is when the focus is on another field and the calendar is opened, it's sets the date to the last 'selector' called by the setDate method...
Here is a jsFiddle that reproduces the problem I am facing.
To reproduce the problem.
Any way to avoid this?
Upvotes: 0
Views: 49
Reputation: 3110
Maybe try to detect if one of your inputs already has focus, then refresh it after the auto-populate of dt3. Seems kind of hackish though.
$("input").datepicker();
setTimeout(function () {
var focused = $('input:focus');
$('#dt3').datepicker('setDate', new Date());
if (focused) {
focused.datepicker('refresh');
}
}, 5000);
Upvotes: 1