dart - Retrieving the selected item in a paper-element dropdown -


i have following code following examples @ https://github.com/dart-lang/polymer-core-and-paper-examples/blob/master/web/paper_dropdown.html , https://github.com/dart-lang/polymer-core-and-paper-examples/blob/master/web/paper_dropdown.dart

edited

.html

<paper-dropdown-menu    label='click select..'    on-core-select='{{oncoreselectcountryhandler}}'>   <paper-dropdown class='dropdown'>     <core-menu id='country' class='menu'>       <template repeat='{{country in countries}}'>         <paper-item>{{country.name}}</paper-item>       </template>     </core-menu>   </paper-dropdown> </paper-dropdown-menu> 

.dart

final list<country> countries = [   const country('afghanistan', 'af'),   const country('Ă…land islands', 'ax')];  class country {   final string name;   final string code;   const country(this.name, this.code); }  void oncoreselectcountryhandler(dom.customevent e, var detail) {     var detail = new jsobject.frombrowserobject(e)['detail'];    if (detail['isselected']) {   // not work - how selection attempted below   // detail should related country class     // can't seem relate selection.   var kuntry = (detail['item'] paperitem).text;  } 

how retrieve selected element in dropdown (that displays normally) using dart code?

update

i think easiest way

void oncoreselectcountryhandler(dom.customevent e, var detail) {   print(countries[$['country'].selected].name);   // or if need access `<paper-item>` element   print(detail['item'].text); } 

old

there no selected in paper-dropdown. wrap core-menu within paper-dropdown provides selected.

see
- https://www.polymer-project.org/0.5/docs/elements/core-menu.html , example @ https://www.polymer-project.org/0.5/docs/elements/paper-dropdown-menu.html


Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -