Skip to content

Conversation

@rjmackay
Copy link
Contributor

Making it easier to work with list items by giving them unique ids.

@fonji
Copy link
Contributor

fonji commented Jul 7, 2014

+1

@iabw
Copy link
Contributor

iabw commented Aug 28, 2014

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants