Preventing browser timeout when using jQuery tree plugin
I am using Ludo van den Boom treeTable jquery plugin to present a table as an expandable tree. Once my dataset is large both Firefox and IE time out when making a plugin call on my $ (document) .ready.
Public plugin method:
$.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 is called from:
$(document).ready(function() {
$(".reportTable").treeTable();
});
Where reportTable is a rather large table class. initialize is a recursive call.
Can this be changed to avoid the timeouts that both browsers give? I saw a link to using setTimeout (see question # 779379), but I'm not sure how to apply that.
How big is the dataset 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 much faster. This version can be downloaded from the project page.