Jquery 此日期选择器的未捕获缺少实例数据

Jquery 此日期选择器的未捕获缺少实例数据,jquery,datepicker,Jquery,Datepicker,在焦点上,我的选择器创建一个动态id,用于datepicker对象,只有datepicker月、年和prev/next按钮不起作用 $(document).on('focus', ".gfield_list_container tr td:nth-child(2) input" , function(){ // Gforms doesn't give list fields new ids so we must do it ourselves to enable date picker to

在焦点上,我的选择器创建一个动态id,用于datepicker对象,只有datepicker月、年和prev/next按钮不起作用

$(document).on('focus', ".gfield_list_container tr td:nth-child(2) input" , function(){
 // Gforms doesn't give list fields new ids so we must do it ourselves to enable date picker to work
 $(this).attr('id', makeid());
 $(this).removeClass('hasDatepicker');
 $(this).datepicker({ dateFormat: 'dd/mm/yy' });
});
如图所示:

我四处搜索了一下,发现了这个:

$(this).live('focus', function(){
    $(this).datepicker({ 
        dateFormat: 'dd/mm/yy',
        changeMonth: true,
        changeYear: true,
        yearRange: '1930:'+(new Date).getFullYear()         
    });
});

使用这种方法,我必须首先在日期字段外单击,然后在其内单击以激活日期选择器。一旦它可见,而上一个/下一个按钮和月/年现在似乎可以正常工作,我仍然无法选择我需要的日期,而且月份的周期不会超过3月份?

您是否使用jQuery UI中的datepicker?如果是,请从他们显示的代码开始作为示例

然后,一旦它工作,调整它,因为你需要

无论如何,如果您是根据您给出的示例进行工作,可以尝试:

$(document).on('focus', ".gfield_list_container tr td:nth-child(2) input" , function(){
 // Gforms doesn't give list fields new ids so we must do it ourselves to enable date picker to work
 $(this).attr('id', makeid());
 $(this).datepicker({
      dateFormat: 'dd/mm/yy',
      changeMonth: true,
      changeYear: true,
      yearRange: '1930:'+(new Date).getFullYear()});
});

你能创建一些fiddle或JSsnippet,这样我们就更容易帮助你了吗?使用上面的选项,select和previous/next现在似乎可以工作了,但是,出于某种原因,我似乎不能循环过3月份。另一个问题是,当点击一个日期时,我会被带回到窗口顶部,而没有从日期选择器中选择任何内容。值得注意的是,我在这一页上有3个日期选择器。