I am using Ludo van den Boom's treeTable jquery plugin to represent a table as a expandable tree. Once my data set becomes large both Firefox and IE timeout on executing the call to the plugin in my $(document).ready.
我使用Ludo van den Boom的treeTable jquery插件将表格表示为可扩展树。一旦我的数据集变大,Firefox和IE就会在$(document).ready中执行对插件的调用时超时。
The plugin's public method is:
该插件的公共方法是:
$.fn.treeTable = function(opts) {
options = $.extend({}, $.fn.treeTable.defaults, opts);
return this.each(function() {
$(this).addClass("treeTable").find("tbody tr").each(function() {
// Initialize root nodes only whenever possible
if (!options.expandable || $(this)[0].className.search("child-of-") == -1) {
initialize($(this));
}
});
});
};
It gets called from:
它来自:
$(document).ready(function() {
$(".reportTable").treeTable();
});
Where reportTable is the class of a fairly large table. initialize is a recursive call.
其中reportTable是一个相当大的表的类。 initialize是一个递归调用。
Can this be modified to to avoid the timeouts both browsers give? I've seen a reference to using setTimeout ( See question #779379) but I am not sure how to apply that.
可以修改它以避免浏览器给出的超时?我已经看到了使用setTimeout的引用(参见问题#779379),但我不确定如何应用它。
2 个解决方案
#1
any function called from setTimeout or setInterval runs outside the main loop and therefore won't block other scripts. It's as simple as:
从setTimeout或setInterval调用的任何函数都在主循环外部运行,因此不会阻止其他脚本。它很简单:
window.onload = function(){setTimeout("your_function()",0)}
#2
How large is the data set that you are using? how many nodes are in the tree? And how many root nodes does it have?
您使用的数据集有多大?树中有多少个节点?它有多少个根节点?
You might want to check out version 2.2.2 of the treeTable plugin, which should initialize large trees a lot faster. This version can be downloaded at the plugin's project page.
您可能需要查看treeTable插件的2.2.2版,它应该可以更快地初始化大型树。该版本可以在插件的项目页面下载。
#1
any function called from setTimeout or setInterval runs outside the main loop and therefore won't block other scripts. It's as simple as:
从setTimeout或setInterval调用的任何函数都在主循环外部运行,因此不会阻止其他脚本。它很简单:
window.onload = function(){setTimeout("your_function()",0)}
#2
How large is the data set that you are using? how many nodes are in the tree? And how many root nodes does it have?
您使用的数据集有多大?树中有多少个节点?它有多少个根节点?
You might want to check out version 2.2.2 of the treeTable plugin, which should initialize large trees a lot faster. This version can be downloaded at the plugin's project page.
您可能需要查看treeTable插件的2.2.2版,它应该可以更快地初始化大型树。该版本可以在插件的项目页面下载。