I have not yet been able to find the documentation on this subject (maybe someone else might be more lucky), but the events you are looking for are iron-select and iron-deselect . Both of these events use a handler format: eventHandler(e, details) , in which:
e is CustomEvent .details - an object with the item property indicating the item that was selected or canceled.
I created a demo on Plunker that you can play with. It has an example menu and will record both e and details from the iron-select and iron-deselect in the console.
However, if you can avoid using the event and use bindings instead, I would recommend this route first. If this is in the user element, you can, for example, do:
<dom-module id="my-custom-element"> <template> <div> <span>[[selectedMessage]]</span> <span>[[oldSelectedMessage]]</span> </div> <paper-menu selected="{{selectedIndex}}"> <paper-item>This is item #0</paper-item> <paper-item>This is item #1</paper-item> <paper-item>This is item #3</paper-item> </paper-menu> </template> </dom-module> <script> Polymer({ is: 'my-custom-element', properties: { selectedIndex: { type: Number, value: 0, observer: '_selectedIndexChanged' } }, _selectedIndexChanged: function(newIndex, oldIndex) { if (typeof newIndex === 'number') { this.selectedMessage = 'You selected item #' + newIndex + '.'; } if (typeof oldIndex === 'number') { this.oldSelectedMessage = 'Before, you had item #' + oldIndex + ' selected.'; } } }); </script>
Adaline Valentina Simonian
source share