Open
Description
Hello hello,
apologies for the basic question but I am using struggling to send the originalArray and the newArray with the new order of the elements.
Any tips welcome !
the JS:
var sortable = Sortable.create(selection, {
handle: '.bars-move',
animation: 150,
});
var modalForm = document.getElementById("modalForm");
if (modalForm !== null ){
modalForm.addEventListener('submit', function(e) {
var formData = new FormData(modalForm);
e.preventDefault();
var request = new XMLHttpRequest();
request.open(modalForm.method, modalForm.action, true);
var cookies = parse_cookies();
request.setRequestHeader('X-CSRFToken', cookies['csrftoken']);
// var originalArray = ????;
var newArray = [...document.querySelectorAll("#selection > tr")].map(el => el.getAttribute("data-id"));
formData.append('newArray', JSON.stringify(newArray));
request.send(formData);
});
};
In the code above, newArray sends the new array - no problem - but I have no idea how to write originalArray.
thank you.