[英]Tabulator.js accessibility by id does not work
The accessibility of a Tabulator Table by a global variable works fine, but i can't realy use global Variables, because i'm dynamically generating new Tables.全局变量对制表符表的可访问性工作正常,但我不能真正使用全局变量,因为我正在动态生成新表。
I just want to access the Tabels by their Container ID.我只想通过它们的容器 ID 访问 Tabels。
The code below shows accessability by global variable "table" and by ID, which is provided by the examples ( http://tabulator.info/examples/4.3#adddel ), but does not work.下面的代码显示了全局变量“表”和 ID 的可访问性,这由示例 ( http://tabulator.info/examples/4.3#adddel ) 提供,但不起作用。
See my JSFiddle example of this: https://jsfiddle.net/vs43re6p/41/请参阅我的 JSFiddle 示例: https ://jsfiddle.net/vs43re6p/41/
$('#button').click(function() {
table.addRow({});
});
$('#button2').click(function() {
$("#example-table").tabulator("addRow", {});
});
What am i doing wrong?我究竟做错了什么?
If you want to use jQuery selection you need to have the Tabulator jQuery wrapper installed:如果要使用 jQuery 选择,则需要安装 Tabulator jQuery 包装器:
http://tabulator.info/docs/4.3/install#setup-jquery http://tabulator.info/docs/4.3/install#setup-jquery
Maybe something like this...也许像这样......
$('#button2').click(function() {
const table = new Tabulator("#example-table");
table.addRow({});
});
or或者
(function() {
const table = new Tabulator("#example-table");
$('#button2').click(function() {
table.addRow({});
});
})();
As long as you are using Tabulator 4.5 or above you can lookup a table by the element ID by using the findTable function on the Tabulator
prototype只要您使用的是 Tabulator 4.5 或更高版本,您就可以使用
Tabulator
原型上的findTable函数通过元素 ID 查找表格
var table = Tabulator.prototype.findTable("#example-table")[0]; // find table object for table with id of example-table
The findTable function will return an array of matching tables. findTable函数将返回匹配表的数组。 If no match is found it will return
false
如果未找到匹配项,它将返回
false
Full details can be found in the Options Documentation完整的详细信息可以在选项文档中找到
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.