Hi guys, I was wondering if anyone knew a way of hiding duplicate (in terms of a name field) items displayed in a collection list. At the moment I have created a form which allows users to submit locations, but now multiple duplicates of the locations can be submitted.
You can use this snippet if the duplicates are based on text. Replace “.filter-component” with your own class that you wish to loop through.
document.addEventListener("DOMContentLoaded", function dumpDups() {
const rr = new Set();
for (const div of document.querySelectorAll(".filter-component")) {
if (rr.has(div.textContent.trim())) {
div.parentNode.removeChild(div);
}
rr.add(div.textContent.trim());
}
dumpDups();
});