开发者

JQuery & cloning huge table

开发者 https://www.devze.com 2023-01-11 01:52 出处:网络
I have a huge table, 1 row with around 2600 columns (it\'s a Gantt chart) What I\'m trying to do is to clone this table and copy it 100 times to somewhere on the page (instead of redraw the table 100

I have a huge table, 1 row with around 2600 columns (it's a Gantt chart)

What I'm trying to do is to clone this table and copy it 100 times to somewhere on the page (instead of redraw the table 100 times as it seems to be less efficient, I can be wrong though)

var $templateTable = $("div#GTT_TLayout").clone();
//there are 100 divs matching it
$("div[id ^= 'taskgrid_bar_' ]").each(function(){  
    ...
    $(this).before($templateTable.html());
});

The issue is that some customers experience this "script time out" issue.

So the 开发者_如何转开发question I have is, is there a better way to do this that is more efficient?

Thanks a lot


You might as well do the .html() call on the $templateTable outside of the .each since there is no point in calling that 100 times. That should help a little anyways.

0

精彩评论

暂无评论...
验证码 换一张
取 消