JQuery UI DatePicker - How to manually open a datepicker
How can a manually op开发者_如何学运维en a datepicker for js code?
To show the datepicker associated to the input with id 'your_elem', you would use something like this:
jQuery('#your_elem').datepicker("show");
$('#datepickerid').focus()
should do the trick.
for me, neither of the suggested solutions work. the date picker opens, but then immediately it closes. so I solved this by using:
setTimeout('$("#datepicker_element").focus();', 320);
hope this helps someone
I had this problem (datepicker was a part of a Drupal module in this case) and for me worked this:
$('input.date').focus();
$('input.date').click();
It didn't work when only $('input.date').click();
was used.
Did work for me:
setTimeout(function(){$("input#element_id").focus();}, 200);
$(function () {
$('#DatePicker').datepicker({
duration: '',
showTime: true,
constrainInput: false,
maxDate: '+1y',
minDate: '-0d',
defaultDate: ''
});
});
精彩评论