Closed miztroh-zz closed 8 years ago
oops. I swear that code worked the first couple times I tried in the Chrome 64 Dev browser, but now I'm getting console errors:
Uncaught TypeError: Cannot set property selectedItems of #
See the doc here:
selectedItems
is read-only. selectedValues
is read/write. Setting that should clear the selection.
Note that selectedValues
doesn't reflect, so if you're looking at the element in the inspector, and selectedValues
was set to a literal array in markup, you'll see the original value on the attribute (like, selected-values="[1,3]"
) in the DOM tree. This isn't a problem and it doesn't affect data binding or anything else -- I just mention it because it's a potential source of confusion.
I believe that this issue has been resolved. Please re-open if it is still unclear how to clear the selected items!
I don't know if there's a clear() function, but setting the selectedItems and selectedValues to [] seems to work. For example if you have an iron-selector with id="selector": this code clears the selected items. this.$.selector.selectedItems=[]; this.$.selector.selectedValues=[];