I created a function for reusing the splice feature for javascript arrays however, after I run it once, it cannot be reused.
var removePerson = function(d, person_id) {
var person_index = d.findIndex(i => i.id == person_id);
d.splice(person_index, 1);
return d;
};
I am not getting console errors. I do not know how to debug it. Here is my JSFiddle.
If you run the example, you will see you can remove any 1 person from the list, but when you try to remove either of the remaining 2, nothing happens (e.g. console errors, console response). Any idea how I can support reuse for my removePerson() function?
populateList, all the event handlers attached using$(".delete").on("click"are gone - you'll want to look into Event Delegation - or you can re-attach the event handlers after every call topopulateList