How to get all elements by class created in a template "dom-repeat"

62 views
Skip to first unread message

Colin Cannon

unread,
Apr 14, 2016, 7:31:06 PM4/14/16
to Polymer
How can I select and add an additional class to all elements of a certain class that were created by a dom-repeat?  For example:

<template is="dom-repeat" items="{{foo}}>
 
<div class="bar">{{item.spot}}</div>
</template>
 
In the Polymer() definition, how can I add an additional class, "secondClass" to add the div's with the class "bar"?

this.$$(''bar") only returns the first div

Karl Tiedt

unread,
Apr 14, 2016, 7:34:21 PM4/14/16
to Colin Cannon, Polymer

Why not make class a computed binding? Otherwise use this.querySelectorAll the $$ is a wrapper for the singular

Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/75ebd564-30e0-45cf-939c-d7d4946d788d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Arthur Evans

unread,
Apr 18, 2016, 1:30:48 PM4/18/16
to Karl Tiedt, Colin Cannon, Polymer
Yep. The general advice is to manipulate the model, not the DOM instances.

For one thing, if you update the DOM instances and then re-sort the list, you'll may need to remember which nodes you updated imperatively and clear them.

OK
Arthur



Reply all
Reply to author
Forward
0 new messages