I am using finsweet list nest to populate links like (tags). which works as required my problem is that then there are duplicates. To get around this I tried using custom code:
<script>
var seen = {};
$('a').each(function() {
var txt = $(this).text();
if (seen[txt])
$(this).remove();
else
seen[txt] = true;
});
</script>
which results in showing duplicate as combination within each collection list. and i want it to resolve duplicates across all items no matter what collection list they are in.
Thanks…. but I have solved this now it needed the finsweet callback, but as the attributes v2 is more recent release i couldn’t find any example how to implement this. I was trying with attributes v1 without knowing - The solution for attributes v2 below if anybody has the same issue
Yep, the Finsweet fs-attributes v2 needs the onLoad callback to ensure deduping runs after the DOM updates. Had the same issue on a tag system for a client. This worked:
window.fsAttributes = window.fsAttributes || [];
window.fsAttributes.push([
'nest',
(listInstances) => {
var seen = {};
$('a').each(function () {
var txt = $(this).text();
if (seen[txt]) $(this).remove();
else seen[txt] = true;
});
},
]);