jquery UI datepicker关闭next()。focus() [英] Jquery UI datepicker closes on next().focus()
问题描述
我需要从datepicker小部件中随后选择两个日期,然后在第一个选择时,我想要关注第二个日期。
我这样设置:
< input type =textclass =dateid = fromDatename =fromDate/>
< input type =textclass =dateid =toDatename =toDate/>
$(input.date)。datepicker({
onSelect:function(){
$(this).next(。date)。 ;
}
});
但是当我选择第一个日期,第二个打开然后关闭窗口...为什么? p>
我看到onClose事件有效,但如果没有选择第一个日期,我不想打开另一个日期...
请尝试从小提琴: http://jsfiddle.net/Ld98p/1/
这很有趣。即使调用datepicker小部件的 show()方法也会产生相同的行为。 / p>
看起来像在 onSelect
中的回调是在一个非常复杂的情况下被调用的,事件性的和触发的 focus
或强制 - 从回调本身显示弹出窗口不能依赖。
但是,触发
$(input.date)。 datepicker({
onSelect:function(){
window.setTimeout($。proxy(function(){
$(this).next(。date)。
},this),10);
}
});
您可以在您更新的小提琴。
I need to select subsequently two dates from a datepicker widget, then I want to focus on the second when the first one is selected. I set it up like this:
<input type="text" class="date" id="fromDate" name="fromDate"/>
<input type="text" class="date" id="toDate" name="toDate"/>
$("input.date").datepicker({
onSelect: function(){
$(this).next(".date").focus();
}
});
But when I select the first date the second opens then closes the window... why?
I saw that with onClose event works, but I don't want to open the other date if the first one is not selected...
Please try it from fiddle: http://jsfiddle.net/Ld98p/1/
That's interesting. Even calling the show() method of the datepicker widget results in the same behavior.
It looks like the onSelect
callback is invoked in a pretty complex situation, events-wise, and triggering focus
or force-showing the popup from the callback itself cannot be relied upon.
However, triggering focus
from a slightly delayed function appears to work:
$("input.date").datepicker({
onSelect: function() {
window.setTimeout($.proxy(function() {
$(this).next(".date").focus();
}, this), 10);
}
});
You can test it in your updated fiddle.
这篇关于jquery UI datepicker关闭next()。focus()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!