where can i find a list of "on-events"?

759 views
Skip to first unread message

Colin Cannon

unread,
Feb 8, 2016, 3:13:20 PM2/8/16
to Polymer
I am using a paper-dropdown-menu.  I want to fire a custom event when the drop down is changed (maybe on-change?). I couldn't find instructions in the docs on how to do this.  Anybody know a list of on-events that I can use with polymer elements?  I am sure it is in the docs somewhere, but I am having no luck finding it.

Karl Tiedt

unread,
Feb 8, 2016, 3:16:43 PM2/8/16
to Colin Cannon, Polymer

-Karl Tiedt

On Mon, Feb 8, 2016 at 12:13 PM, Colin Cannon <colin...@gmail.com> wrote:
I am using a paper-dropdown-menu.  I want to fire a custom event when the drop down is changed (maybe on-change?). I couldn't find instructions in the docs on how to do this.  Anybody know a list of on-events that I can use with polymer elements?  I am sure it is in the docs somewhere, but I am having no luck finding it.

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/0fc3e249-6d68-4802-9a55-9ef28110dfe0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Colin Cannon

unread,
Feb 8, 2016, 3:23:13 PM2/8/16
to Polymer, colin...@gmail.com
Hi Karl, thanks for the reply.  I did see those events listed, but I am looking for something like an on-change event to fire when the selected value of the drop down changes.  For instance, right now as a test I have:

on-click="_test"

as an attribute in my paper-dropdown-menu element, and that is not listed anywhere on that doc page, but it does fire an event when clicked.  

*maybe I should have asked for on-event attributes

Karl Tiedt

unread,
Feb 8, 2016, 3:33:27 PM2/8/16
to Colin Cannon, Polymer
Ahhh gotcha, that would be the 'on-value-change' or maybe -changed I forget which it is... basically ANY property will fire an on-*-change[d] event, which I believe requires that property to be notify:true (but could be wrong).

-Karl Tiedt

dssc...@gmail.com

unread,
Feb 8, 2016, 4:11:03 PM2/8/16
to Polymer, colin...@gmail.com
You are right Karl that a property requirese `notify: true` to fire on-propertyname-changed events.

Arthur Evans

unread,
Feb 11, 2016, 9:32:34 AM2/11/16
to Colin Cannon, Polymer
If you're using a paper-menu (or a paper-listbox) inside a paper-dropdown-menu as shown in the example on the paper-dropdown-menu docs, then the paper-menu fires an iron-select event when the selected item changes (https://elements.polymer-project.org/elements/paper-menu#event-iron-select). The paper-dropdown-menu fires events when it's opened or closed.

Here's a bin showing listening to the iron-select event:


So we're clear, there's no list of on- event attributes. Polymer supports this as a general pattern. on-<event-name> adds an event listener for <event-name>. That event name can be a standard DOM event like click, a Polymer gesture event like tap, or an element-specific event like iron-select. 

As Karl said, any property with notify: true also generates an event. You could also listen for _those_ with on-<property-name-changed>, like, on-value-changed, on-selected-item-label-changed, and so on.

The paper-dropdown-menu doc is a little unclear, but the meaning of the 2nd paragraph is that you can specify any menu element you like (paper-menu, paper-listbox, or an element of your own). If you create a new element here, it needs to fire an iron-select event when a new item is selected, and the event's detail.item should be the selected item.


I'll submit a PR to try and make this part of the API doc a little clearer.

Hope that helps.

On Mon, Feb 8, 2016 at 8:13 PM, Colin Cannon <colin...@gmail.com> wrote:
I am using a paper-dropdown-menu.  I want to fire a custom event when the drop down is changed (maybe on-change?). I couldn't find instructions in the docs on how to do this.  Anybody know a list of on-events that I can use with polymer elements?  I am sure it is in the docs somewhere, but I am having no luck finding it.

Follow Polymer on Google+: plus.google.com/107187849809354688692
Reply all
Reply to author
Forward
0 new messages