javascript - Show table generation as it generates? -


i'm generating table using jquery appending rows etc table , returning it. there way show table generates? populating goes , using way of showing progress.

ui.generate_tabs('content-tabs', content_container, domain_list, function(domain_id) {                 var table = jquery('<table><thead><th>backbone</th><th>sequence</th></thead></table>');                 var tbody = jquery('<tbody/>');                 table.append(tbody);                  var show_table = function(table) {                     console.log(table);                     return table;                 }                  (let aacid of utils.map_iterkeys(aacid_str)) {                         var tr = jquery('<tr/>');                         tbody.append(tr);                         tr.append(jquery('<td/>').text(aacid));                         tr.append(jquery('<td class="single-line-td"><code>' + aacid_str[aacid] + '</code></td>'));                         show_table(table);                 };                  // // job done                 progress_indicator.remove();                 return table; 

you'll have use either native settimeout() function or jquery .delay() method let browser process dom rendering.

instead of doing:

for(var n = 0; n < n_row; n++) {   appendrow(n); } 

you'd do:

var n = 0,     iter;  (iter = function() {   if(n < n_row) {     appendrow(n++);     settimeout(iter, delay);   } })(); 

where 'delay' expressed in milliseconds , may 0 or other arbitrary value. note delay = 0, process take more time 'standard way'.

edit: others noticed, doesn't make sense unless plan slow down on purpose (with, say, delay = 500) show user 'hey, look! i'm adding new rows!'


Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -