【问题标题】:datatables/yadcf with new api isn´t working with dom-onclick带有新 api 的数据表/yadcf 不适用于 dom-onclick
【发布时间】:2018-02-26 21:23:48
【问题描述】:

我正在使用数据表、yadcf-plugin 和 exResetAllFilters 来重置所有列过滤器。

我最近切换到“新 api”(yadcf.init),但 dom onclick 不再工作了。 错误是:

Uncaught ReferenceError: table is not defined at HTMLInputElement.onclick

我知道我可以用 $("#reset2").click 做到这一点,但我有兴趣了解为什么不再工作。

为了更好的解释,我做了两个示例:http://live.datatables.net/yavayasa/2/edithttp://live.datatables.net/xofaluli/3/edit

【问题讨论】:

    标签: datatables yadcf


    【解决方案1】:

    它与 yadcf 无关,在该示例中,您在 $(document).ready( function () { 函数中声明了您的 table 变量,并且由于 js var 存在于函数范围内,因此对于调用它是未定义的在该功能之外制作,

    解决方案:在函数外部声明table 变量see example

    var table;
    $(document).ready( function () {
    ...
    

    【讨论】:

    • 谢谢,非常感谢。
    猜你喜欢
    • 2014-08-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-08
    • 1970-01-01
    • 2014-07-02
    • 2015-03-31
    相关资源
    最近更新 更多