2013-01-18 50 views
0
$(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日期选择器,通过它可以选择“Month-Year”,它可以很好地与除iPad以外的每个浏览器一起工作。请看附带的图像。 error with jQuery DatepickerjQuery datepicker不能与iPad一起工作

回答

1
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(); 
      } 
     }); 
    }); 
0

我建议你使用Chrome开发者工具(F12)

设置>覆盖> “用户代理” 选择的iPad。

Chrome和Safari都使用WebKit。您可以轻松模拟iPad并进行调试。

+0

即使使用这个,我不能重现一个问题,那是在ipad,safari和chome上。所以仿真不是100%正确的 – Miguel