My scenario: I have a table with four rows. The first three rows are filled with data and the fourth row is blank. I highlight the entire first three rows, copy, then paste into the fourth row. Handsontable generates two new rows to make room for the pasted data.
My problem: The afterCreateRow event fires twice, and each time the amount is 1. I would expect it to fire once with an amount of 2, since Handsontable knows in advance that two rows must be created.
Here is a jsfiddle that demonstrates the phenomenon.
Here is what I'm trying to do:
function afterCreateRow(row, amount) {
for (var i = row; i < row + amount; i++) {
model.initializeNewRow(i);
model.calculator.cascadeRow(i);
model.calculator.calculateRow(i);
}
model.calculator.updateTotals();
model.history.submitBatch();
}
I only want to call submitBatch once for each user action. How can I achieve this?