Reputation: 8071
I am manually triggering selection of an item when a certain element is clicked. This works fine as long as I have selection-enabled multi-selection
attributes on my iron-list. However, I would like to remove them because the associated event handlers (select on tap) interfere with mine. When I do I get polymer.html:3942 Uncaught TypeError: userArray.slice is not a function
Some loggging shows that _itemsChanged
is doing
Polymer.Collection.get(this.items)
which expects an array of all items further down the chain, but is getting just the selected item as an object. So I've found the problem, but I don't know why it's happening or how to fix it.
It looks in the code like selection-enabled
is just adding the handlers. Is that a wrong assumption? Is it always needed to do selections? Is there something wrong with my function perhaps?
This is my select function, adapted from the _selectItem
function in this post's jsbin :
toggleSelect: function(e) {
this.$.itemsList.toggleSelectionForItem(e.model.item);
},
My apologies as this question is a bit rushed. I will try to provide a fiddle later.
Upvotes: 0
Views: 145
Reputation: 8071
The code in the original post is correct, the solution is to use multi-selection
but not selection-enabled
.
Since toggleSelectionForItem
appears to depend on multi-selection
and it is selection-enabled
that fires the unwanted select we can simply remove selection-enabled
to get the desired behavior.
Upvotes: 0
Reputation: 2964
try changing selectedItem property instead of calling the method toggleSelectionForItem. From the description of this method it seems that it is more related to multi select property.
Upvotes: 1