Set value to vaadin combobox(polymer) -


i have system can select value in vaadin-combobox or select value in div (with svg) , set combo's value dynamically. how can set combo's value?

i tried value="", didn't work...

update bind combobox's value first array item, you'd use computed binding:

<vaadin-combo-box   value="[[_getfirstitem(sessions)]]"   ...> </vaadin-combo-box> 

where _getfirstitem() method on polymer object:

polymer({   is: 'x-foo',   ...   _getfirstitem: function(sessions) {     return sessions.length > 0 && sessions[0];   } }); 

<head>    <base href="https://polygit.org/polymer+1.5.0/components/">    <script src="webcomponentsjs/webcomponents-lite.min.js"></script>    <link rel="import" href="https://cdn.vaadin.com/vaadin-core-elements/master/vaadin-combo-box/vaadin-combo-box.html">  </head>  <body>    <x-foo></x-foo>      <dom-module id="x-foo">      <template>        <vaadin-combo-box          label="element"          items='[[sessions]]'          value="[[_getfirstitem(sessions)]]">        </vaadin-combo-box>      </template>      <script>        htmlimports.whenready(function() {          polymer({            is: 'x-foo',            properties : {              sessions: {                type: array,                value: function() {                  return ["bohrium", "boron", "bromine", "cadmium", "caesium", "calcium"];                }              }            },            _getfirstitem: function(sessions) {              return sessions.length > 0 && sessions[0];            }          });        });      </script>    </dom-module>  </body>

codepen


from docs vaadin-combobox:

you need provide set of items user can select items property. current selection indicated value , selecteditem properties. can set or change selection programmatically setting value property. doing updates visible fields.

when setting items declaratively, notice attribute value needs valid json string. need use single quotes attribute value , double quotes inside value (in json string). alternatively, can escape double quotes inside value.

<vaadin-combo-box   label="element"   items='["bohrium", "boron", "bromine", "cadmium", "caesium", "calcium"]'   value="bromine"> </vaadin-combo-box> 

setting items , value programmatically:

var combobox = document.queryselector('vaadin-combo-box'); combobox.items = ['bohrium', 'boron', 'bromine', 'cadmium', 'caesium', 'calcium']; combobox.value = 'bromine';