Awesome. Just as you posted that I came to a similar conclusion and am able
to reproduce exactly the same thing as you did. The only thing is that I
need to have access to the top level element within poly-list. The reason
for this is because I need to change some css on it when it is clicked. For
example:
<poly-list data="{{ data.in }}">
<template>
<div> <!-- on-click on this element without user defining it -->
<span>Repeated content</span>
</div>
</template>
</poly-list>
By top level in poly-list I mean that div element.
On Monday, August 25, 2014 7:27:34 PM UTC-7, Rob Dodson wrote:
Here's an example which adds a listener to the element itself and then
> alerts the event target's textContent: http://jsbin.com/getem/4/edit
>
>
> On Mon, Aug 25, 2014 at 7:16 PM, 'Steve Orvell' via Polymer <
> [email protected] <javascript:>> wrote:
>
>> It's best not to directly touch elements rendered via a template repeat.
>> To do so you'd need to setup a MutationObserver and possibly deal with the
>> elements being removed.
>>
>> For this use case you can leverage event bubbling to delegate the event
>> up the tree to a declarative event handler in the dom above the individual
>> template items. You can then use event.target or possibly event.path to get
>> the target of interest.
>>
>>
>> On Mon, Aug 25, 2014 at 6:45 PM, <[email protected] <javascript:>>
>> wrote:
>>
>>> EDIT TO ORIGINAL POST: I did not mean to include the on-click event on
>>> the div in my code. This was for an example of where the on-click event
>>> should be.
>>>
>>> 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 [email protected] <javascript:>.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/polymer-dev/231d8198-1f2f-47ec-a934-57346fb19c54%40googlegroups.com
>>>
>>> <https://groups.google.com/d/msgid/polymer-dev/231d8198-1f2f-47ec-a934-57346fb19c54%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> 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 [email protected] <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/polymer-dev/CA%2BrMWZhb%3DUQe0ArGbgUJ%3DUvmAoavj6aM6diMvK3CNzJMA%3DNE1w%40mail.gmail.com
>>
>> <https://groups.google.com/d/msgid/polymer-dev/CA%2BrMWZhb%3DUQe0ArGbgUJ%3DUvmAoavj6aM6diMvK3CNzJMA%3DNE1w%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
On Monday, August 25, 2014 7:27:34 PM UTC-7, Rob Dodson wrote:
>
> Here's an example which adds a listener to the element itself and then
> alerts the event target's textContent: http://jsbin.com/getem/4/edit
>
>
> On Mon, Aug 25, 2014 at 7:16 PM, 'Steve Orvell' via Polymer <
> [email protected] <javascript:>> wrote:
>
>> It's best not to directly touch elements rendered via a template repeat.
>> To do so you'd need to setup a MutationObserver and possibly deal with the
>> elements being removed.
>>
>> For this use case you can leverage event bubbling to delegate the event
>> up the tree to a declarative event handler in the dom above the individual
>> template items. You can then use event.target or possibly event.path to get
>> the target of interest.
>>
>>
>> On Mon, Aug 25, 2014 at 6:45 PM, <[email protected] <javascript:>>
>> wrote:
>>
>>> EDIT TO ORIGINAL POST: I did not mean to include the on-click event on
>>> the div in my code. This was for an example of where the on-click event
>>> should be.
>>>
>>> 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 [email protected] <javascript:>.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/polymer-dev/231d8198-1f2f-47ec-a934-57346fb19c54%40googlegroups.com
>>>
>>> <https://groups.google.com/d/msgid/polymer-dev/231d8198-1f2f-47ec-a934-57346fb19c54%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>> 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 [email protected] <javascript:>.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/polymer-dev/CA%2BrMWZhb%3DUQe0ArGbgUJ%3DUvmAoavj6aM6diMvK3CNzJMA%3DNE1w%40mail.gmail.com
>>
>> <https://groups.google.com/d/msgid/polymer-dev/CA%2BrMWZhb%3DUQe0ArGbgUJ%3DUvmAoavj6aM6diMvK3CNzJMA%3DNE1w%40mail.gmail.com?utm_medium=email&utm_source=footer>
>> .
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
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 [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/polymer-dev/a6160398-8381-431f-a434-7a4ceee04878%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.