javascript - Handsontable updating cells crashing browser -


ive made simple single column table using handsontable. wanted user able input time in format hh:mm:ss found seconds valid input 120s = 00:02:00. not difficult larger times (hours).

there function format , unformat time in numeral.js library, nice, used it. problem code causes browser go crazy. wanted see how many times code looping , 1 change cell causes 18,000 loop cycles, of time crashing browser. why calling cellproperties.render many times o.o!?

any ideas?

<!doctype html> <html> <head> <script src="https://code.jquery.com/jquery-1.11.1.min.js"></script> <link rel="stylesheet" media="screen" href="http://localhost/handsontable-0.16.0/dist/handsontable.full.css"> <script src="http://localhost/handsontable-0.16.0/dist/handsontable.full.js"></script>  </head> <body> <div id="examplegrid1" class="datatable"></div> <div id="examplegrid2" class="datatable"></div> <script type="text/javascript">     $(document).ready(function () {     var data = [     [0],     [0],     [0],     [0],     [0],     [0],     [0],     ];   function valuerenderer2(instance, td, row, col, prop, value, cellproperties) {         handsontable.renderers.numericrenderer.apply(this, arguments);          var = numeral().unformat(td.innerhtml);          console.log(a + 'this');         value = 'test';             $('#examplegrid1').handsontable('setdataatcell', row, 0, a);  } var call = 0 var $container = $("#examplegrid1");  $container.handsontable({     data: data,     colheaders: ['time'],     width: 500,      columns: [           {             type: 'numeric',             format: '00:00:00',           },           ],     cells:            function (col, prop) {             var cellproperties = {};             cellproperties.renderer = valuerenderer2;              call++;             console.log("the call on: " + call);             return cellproperties;         }, });        }); </script>  </body> </html> 

the last line in custom valuerenderer2 cell renderer creates implicit recursion, because setdataatcell forces full render on table in turn calls valuerenderer2 again.

if question right need custom cell editor, , not custom renderer. can read more editors here.


Comments