I have the following click handler, when it is clicked I pull in an array from handsontable and then remove the last element from the array, and pass the new array to an ajax post. the issue is that if I click the button again it removes another item from the array. It seems like the data
var
is not being reset to all of the data on click?
$('#view-options').on('click', '#act_add', function() {
var newData = $('#spreadsheet').handsontable("getData");
var data = newData;
newData.pop();
console.log(newData);
console.log(data);
$.ajax({
url: path + "api/v1/apps/add",
data: {"data": newData},
dataType: 'json',
type: 'POST',
success: function(res) {
alertify.success("your data was added to the db");
}
});
});
in the previous code newData
and data
both log the same array, this does not makes sense considering I only pop()
the newData
array