Using distributed node inside a repeat

46 views
Skip to first unread message

e3satt...@gmail.com

unread,
Jul 20, 2015, 1:52:33 PM7/20/15
to polym...@googlegroups.com
Is it possible to use a content block inside of a dom-repeat, say for example, in a repeating list, to be able to inject some parts of list items?


<template is="dom-repeat" items="{{items}}">
  <ul>
    <li>{{item}}<content></content></li>
  </ul>
</template>

It seems like the content is always and only inserted into the first item. Is there a better way to accomplish this?

Daniel Freedman

unread,
Jul 20, 2015, 2:44:39 PM7/20/15
to e3satt...@gmail.com, polymer-dev
That won't work because of how distribution with <content> works. Distributed nodes will fill the first content they match, so your example will have all distributed nodes appear in the first list item. You either have to decorate the nodes for distribution (put a unique class on each item and use <content select=".uniqueClass-%item number%"> in your dom-repeat), or manually move the nodes.

You might want to rethink this design. Maybe it would be easier to wrap each node you want in this list in a <ul> higher up, and just have <li><content></content></li> where you have this dom-repeat.

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/33a1a8b4-e6e3-4f04-8402-6e66c9300a9b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

e3satt...@gmail.com

unread,
Jul 20, 2015, 2:58:52 PM7/20/15
to polym...@googlegroups.com, e3satt...@gmail.com
I'm not tied to anything, really just experimenting. 

My use case is an auto completer using ajax that allows the end user to specify what the drop down choices look like.

So I was trying to do user defined templates basically.

e3satt...@gmail.com

unread,
Jul 20, 2015, 3:00:58 PM7/20/15
to polym...@googlegroups.com, e3satt...@gmail.com
Or is there a way to hook into the repeat logic so I can do something at each step?


On Monday, July 20, 2015 at 1:44:39 PM UTC-5, Daniel Freedman wrote:
Reply all
Reply to author
Forward
0 new messages