我正在使用jquery ui datepicker。
我在页面上有两个日期选择器,from和to日期选择器
当我在一个datepicker中选择一个日期时,我将最大和最小日期更新为第二个datepicker。
我的问题是,就在它关闭(隐藏)选定的日期选择器之前,它显示第二个日期选择器而不是第一个日期选择器(就在我更新第二个日期选择器的最小日期时),然后关闭它。
当我从另一个日期选择器更新最小日期时,为什么它显示第二个日期选择器?
如何在更新第二个日期选择器之前隐藏日期选择器?
<!doctype html>
<html >
<head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.9.1.js"></script>
<script src="//code.jquery.com/ui/1.10.3/jquery-ui.js"></script>
</head>
<body>
<input name="fromDateCalendar" type="text" value="10/12/2013" id="fromDateCalendar" style="width:100px;" />
<input name="toDateCalendar" type="text" value="09/01/2014" id="toDateCalendar" style="width:100px;" />
<script>
$(function () {
$('#fromDateCalendar').datepicker({
onSelect: function (date) {change1(date);}});
$("#toDateCalendar").datepicker({
onSelect: function (date) {change2(date);}, maxDate: '0' });
});
function change1(date) {
$('#toDateCalendar').datepicker('option', 'minDate', date);}
function change2(date) {
$('#fromDateCalendar').datepicker('option', 'maxDate', date);}
</script>
</body>
</html>发布于 2014-01-12 16:32:36
为了解决当我更改最大日期时显示第二个日期选择器(代替第一个日期选择器)的问题,我在使用setTimeout关闭第一个日期选择器之后调用....datepicker('option','minDate',start
onSelect: function (date) {
setTimeout(function () {
....datepicker('option', 'minDate', start)
}, 300)
}....https://stackoverflow.com/questions/21020635
复制相似问题