On Sun, Feb 14, 2016 at 3:08 PM, Pedro Nicolás Cuadra Guamán <
[email protected]> wrote:

> Don't worry, I solved the problem using jQuery:
>
> $("<paper-radio-group>").on("paper-radio-group-changed",function(){
>    //...
> })
>
>
You shouldn't need jQuery, with Polymer or just with plain JS. In fact,
jQquery is dangerous because it doesn't know about the Shady DOM scoping
and will select elements across shadow boundaries.

In a Polymer element, this.$$(s) is an alias for
this.root.querySelector(s), so to add an event handler just do:

this.$$('paper-radio-group').addEventListener('paper-radio-group-changed',
() => { ... });

This query is scoped to the element both in native shadow DOM and in
ShadyDOM.

If you want a document-level handlers, you can just use standard DOM APIs:

document.querySelector('paper-radio-group').addEventListener('paper-radio-group-changed',
() => { ... });

Note that under shady DOM that query won't be scoped to just the document's
light-dom, but will select the first paper-radio-group, even in a shadow.
Same with jQuery. I'd use that pattern with great caution, or better not at
all.

Cheers,
  Justin



> Greetings from Chile
>
> 2016-02-14 18:48 GMT-03:00 Pedro Nicolás Cuadra Guamán <
> [email protected]>:
>
>> PD: I want to control a <paper-radio-group>
>>
>> 2016-02-14 18:47 GMT-03:00 Pedro Nicolás Cuadra Guamán <
>> [email protected]>:
>>
>>> Sorry i'm not expert with Polymer, but, How can I manipulate an
>>> "on-change" event external to the web component in JS? any link? I would
>>> appreciate you so much
>>>
>>>
>>
> 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/CABUE4gjpppD1%2B7CZkaFuXPdZ3sH53cOU26%2BUUdrW5995e%2B_-Zg%40mail.gmail.com
> <https://groups.google.com/d/msgid/polymer-dev/CABUE4gjpppD1%2B7CZkaFuXPdZ3sH53cOU26%2BUUdrW5995e%2B_-Zg%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/CAEKsHmC1t%2Bkfh999_YPi6pnj%3DAQLBtAV9%3Dq_%2BOavFoNbyVkZeg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to