我正在使用Hands on table用于实现类似 excel 表格的插件。我的问题有点奇怪。在我的 javascript 代码中,我在 document.ready 事件中的 div 元素上调用此插件,例如:
$("#vdcontainer").handsontable({
startRows: 2,
startCols: 1,
colHeaders: ["<span style='font-size:15px; font-weight:bolder; width:500px; text-align:center;'>Enter variable data here Or just cut & paste</span>"],
minSpareRows: 1
});
现在到目前为止,一切都很完美,插件在 div 内创建了一个类似 excel 的表格,其 id 为 vdcontainer
。现在,当我单击按钮并从单击事件的处理函数调用此插件时,就会出现问题,如下所示:
$("#vdcontainer").handsontable('loadData', ['a', 'b', 'c', 'd', 'e']);
现在它在控制台上向我显示以下错误消息
Uncaught TypeError: Object [object Object] has no method 'handsontable'
任何人都可以知道为什么对 handsontable 函数的调用在 document.ready 事件上工作正常,但在同一 js 文件中的事件处理函数中不起作用?
最佳答案
您包含的 jQuery 版本可能太旧 - 由于使用 .on,handsontable 插件需要 jQuery 1.7+。
关于javascript - 未捕获的类型错误 : Object [object Object] has no method 'handsontable' ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14032436/