Datatables Datatable datefilter正确加载,但在选择日期时抛出未捕获的TypeError

Datatables Datatable datefilter正确加载,但在选择日期时抛出未捕获的TypeError,datatables,datatables-1.10,Datatables,Datatables 1.10,这个问题只是对给定场景的复制。datatable正确加载,但在选择日期时抛出以下错误。将引发以下错误: Uncaught TypeError: Cannot set property 'currentDay' of undefined at Datepicker._selectDay (jquery-ui.1.12.1.js:8188) at HTMLTableCellElement.selectDay (jquery-ui.1.12.1.js:8789) at HTML

这个问题只是对给定场景的复制。datatable正确加载,但在选择日期时抛出以下错误。将引发以下错误:

Uncaught TypeError: Cannot set property 'currentDay' of undefined
    at Datepicker._selectDay (jquery-ui.1.12.1.js:8188)
    at HTMLTableCellElement.selectDay (jquery-ui.1.12.1.js:8789)
    at HTMLTableCellElement.dispatch (jquery.v1.12.0.min.js:3)
    at HTMLTableCellElement.r.handle (jquery.v1.12.0.min.js:3)
检查 这个问题是众所周知的。例如,如果datepicker元素id为“#datepickerStart”,则在给定页面中只应加载一次。若两个DOM元素具有相同的元素id,则会抛出上述错误

我们主要将其用于中给出的单个字段搜索。当我在浏览器中检查开发人员工具时,我可以看到两个DOM生成了“#datepickerStart”。一个位于正确的搜索区域,另一个位于表格区域的末尾

我对以下代码如何生成这些重复的表列感到困惑。请注意,在注入以下代码或将原始HTML放入搜索文本框时会发生这种情况。

$('#example tfoot th').each(function (){
    var title = $(this).text();

    if (title === "Start date") {
        $(this).html( '<input type="text" id="datepickerStart" placeholder="Search '+title+'" />' );

    } else if (title === "End date") {
        $(this).html( '<input type="text" id="datepickerEnd" placeholder="Search '+title+'" />' );

    } else {
        $(this).html( '<input type="text" placeholder="Search '+title+'" />' );
    }
});
$('#示例tfoot th')。每个(函数(){
var title=$(this.text();
如果(标题==“开始日期”){
$(this.html(“”);
}否则如果(标题==“结束日期”){
$(this.html(“”);
}否则{
$(this.html(“”);
}
});
我是错过了什么,还是做错了?我反复检查了我没有两次初始化datatable,也没有两次创建datePicker元素

你能帮我找出哪里出了问题吗?提前谢谢

编辑1: 表结构创建如下:

<table id='example' class="display" cellspacing="0" width="100%">
        <thead>
            <tr> 
                <th>URL</th>
                <th>Title</th>
                <th>User</th>
                <th>Start date</th>
                <th>End date</th>
                <th>Duration</th>  
            </tr>
        </thead>

        <tfoot>
            <tr>
                <th>URL</th>
                <th>Title</th>
                <th>User</th>
                <th>Start date</th>
                <th>End date</th>
                <th>Duration</th>  
            </tr>
        </tfoot>
    </table>

统一资源定位地址
标题
使用者
开始日期
结束日期
期间
统一资源定位地址
标题
使用者
开始日期
结束日期
期间

我看到的原始html是静态的,为什么不直接将搜索框放入代码中:

    <table id='example' class="display" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>URL</th>
                <th>Title</th>
                <th>User</th>
                <th>Start date</th>
                <th>End date</th>
                <th>Duration</th>
            </tr>
        </thead>

        <tfoot>
            <tr>
                <th><input type="text" placeholder="Search URL"/></th>
                <th><input type="text" placeholder="Search Title"/></th>
                <th><input type="text" placeholder="Search User"/></th>
                <th><input type="text" id="datepickerStart" placeholder="Search Start Date"/></th>
                <th><input type="text" id="datepickerEnd" placeholder="Search End Date"/></th>
                <th><input type="text" placeholder="Search Duration"/></th>
            </tr>
        </tfoot>
    </table>

统一资源定位地址
标题
使用者
开始日期
结束日期
期间

但是说了这么多,我认为你找错了你的错误。show使用您的数据结构和.DataTable()我怀疑列定义与json不完全匹配有问题。

我看到的原始html是静态格式,为什么不直接将搜索框放入代码中:

    <table id='example' class="display" cellspacing="0" width="100%">
        <thead>
            <tr>
                <th>URL</th>
                <th>Title</th>
                <th>User</th>
                <th>Start date</th>
                <th>End date</th>
                <th>Duration</th>
            </tr>
        </thead>

        <tfoot>
            <tr>
                <th><input type="text" placeholder="Search URL"/></th>
                <th><input type="text" placeholder="Search Title"/></th>
                <th><input type="text" placeholder="Search User"/></th>
                <th><input type="text" id="datepickerStart" placeholder="Search Start Date"/></th>
                <th><input type="text" id="datepickerEnd" placeholder="Search End Date"/></th>
                <th><input type="text" placeholder="Search Duration"/></th>
            </tr>
        </tfoot>
    </table>

统一资源定位地址
标题
使用者
开始日期
结束日期
期间

但是说了这么多,我认为你找错了你的错误。show use your data structure and.DataTable()我怀疑列定义与json不完全匹配有问题。

这个问题没有正确的解决方法,但是可以在本文中找到相关的答案
请在“我要结束这篇文章”中继续您的所有建议和答案,因为即使在链接页面中也没有找到一致的行为。

这个问题没有正确的解决方案,但是可以在这篇文章中找到相关的答案
请继续在我即将结束这篇文章中的所有建议和答案,因为即使在链接页面中也没有发现一致的行为。

这里有一些东西供您使用,请看这里:

$(文档).ready(函数(){
//我的日期与你的日期不符,所以这个简单的循环修复了这个问题
对于(变量i=0;i
这里有你可以玩的东西,请看这里:

$(文档).ready(函数(){
//我的日期与你的日期不符,所以这个简单的循环修复了这个问题
对于(变量i=0;i