jQuery datepicker无法使用iPad [英] jQuery datepicker not working with iPad
本文介绍了jQuery datepicker无法使用iPad的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
$(function () {
$('.Month-Picker').datepicker({
changeMonth: true,
changeYear: true,
showButtonPanel: false,
dateFormat: 'MM-yy',
onClose: function (dateText, inst) {
var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
$(this).datepicker('setDate', new Date(year, month, 1));
$("#<%=btnMonthYear.ClientID %>").click();
},
beforeShow: function (input, inst) {
if ((datestr = $(this).val()).length > 0) {
year = datestr.substring(datestr.length - 4, datestr.length);
month = jQuery.inArray(datestr.substring(0, datestr.length - 5), $(this).datepicker('option', 'monthNames'));
$(this).datepicker('option', 'defaultDate', new Date(year, month, 1));
$(this).datepicker('setDate', new Date(year, month, 1));
}
}
});
});
我有一个jQuery日期选择器,通过它我选择月 - 年它适用于每个浏览器除了iPad。请看附上的图片。
I have a jQuery datepicker through which I choose the "Month-Year" Its working fine with every browser except the iPad. Please have look at the enclosed image.
推荐答案
var postForm = false;
$(function () {
$('.Month-Picker').datepicker({
changeMonth: true,
changeYear: true,
showButtonPanel: false,
dateFormat: 'MM-yy',
onChangeMonthYear: function () { postForm = true; },
onClose: function (dateText, inst) {
var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
$(this).datepicker('setDate', new Date(year, month, 1));
$("#<%=btnMonthYear.ClientID %>").click();
},
beforeShow: function (input, inst) {
if ((datestr = $(this).val()).length > 0) {
year = datestr.substring(datestr.length - 4, datestr.length);
month = jQuery.inArray(datestr.substring(0, datestr.length - 5), $(this).datepicker('option', 'monthNames'));
$(this).datepicker('option', 'defaultDate', new Date(year, month, 1));
$(this).datepicker('setDate', new Date(year, month, 1));
postForm = false;
}
}
});
});
$(document).ready(function () {
$("#aspnetForm").click(function () {
if (postForm == true) {
postForm = false;
var month = $("#ui-datepicker-div .ui-datepicker-month :selected").val();
var year = $("#ui-datepicker-div .ui-datepicker-year :selected").val();
$(this).datepicker('setDate', new Date(year, month, 1));
$("#<%=btnMonthYear.ClientID %>").click();
}
});
});
这篇关于jQuery datepicker无法使用iPad的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文