Open rjmackay opened 10 years ago
+1
I haven't explicitly tested it, but I think that this has problems with lists that are meant to be sorted or re-ordered, such as this plugin
If you have 4 items such as this:
[{id:1},{id:2},{id:3},{id:4}]
and you move the last item to the front of the array
[{id:4},{id:1},{id:2},{id:3}]
Your ids (wth the implied order because you're using the length attribute for id) are now confusing.
Even worse, if you now remove the last item
[{id:4},{id:1},{id:2}]
but then add a new one
[{id:4},{id:1},{id:2},{id:4}] //length is 4 again
We have duplicate IDs.
I do not think items.length should be used to generate the id. Instead, I would recommend using the view's cid attribute.
Is there a specific reason you needed the index in the id string? If so, is there a reason you can't index the item against list.items?
Making it easier to work with list items by giving them unique ids.