[英]wrong value returned for month in datepicker of jquery ui when using the next arrow
I am using datpicker to provide options to select the month/year only and when the month is selected, a form is submitted with the selected value. 我正在使用datpicker提供仅选择月份/年份的选项,并且当选择月份时,将提交具有所选值的表单。
here is the code: jquery ui datepicker with this code: 这是代码: jquery ui datepicker具有以下代码:
$(document).ready(function(){
$("#datepicker").datepicker( {
changeMonth: true,
changeYear: true,
showButtonPanel: false,
yearRange: "2013:2015",
onChangeMonthYear: function(dateText, inst) {
console.log($(".ui-datepicker-year :selected",$(this)).val()
+ "/" + $(".ui-datepicker-month :selected",$(this)).val());
}
});
});
but there are two situations when the number returned is wrong. 但是在两种情况下,返回的数字是错误的。
(values in console.log) (console.log中的值)
if you try to select a month lets say oct 2013, returned value is 2013/9, which is ok. 如果您尝试选择一个月份,例如说2013年10月,则返回值为2013/9,可以。 now if you try to click on the arrow to go to nov 2013, again the value is 2013/9 which is wrong.
现在,如果您尝试单击箭头以转到nov 2013,则该值再次为2013/9,这是错误的。 similarly jumping from dec 2013 to jan 2012 returns 2013/11
同样从2013年12月跳至2012年1月,返回2013/11
if you go to the end "dec 2015", and then click the next arrow, it goes back to the beginning "jan 2013", which is ok, but then keep clicking on the next arrow, you will notice you can no longer move from "dec 2013" to "jan 2014", it moves back to "jan 2013" 如果您移至末尾的“ dec 2015”,然后单击下一个箭头,它将返回到开头的“ jan 2013”,这没关系,但是继续单击下一个箭头,您会注意到您将无法再移动从“ 2013年12月”到“ 2014年1月”,然后又回到“ 2013年1月”
any help is appreciated. 任何帮助表示赞赏。
onChangeMonthYear()
receives the newly selected year and month as arguments, so you can just use those directly onChangeMonthYear()
接收新选择的年份和月份作为参数,因此您可以直接使用它们
...
minDate: new Date(2013, 1 - 1, 1),
maxDate: new Date(2015, 12 - 1, 31),
onChangeMonthYear: function(year, month, inst) {
console.log(
year + "/" + month
);
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.