Polymer implement native select element

gabriela

I'm implementing a polymer custom element using a native select with options.

<select id="selectbox" value="{{selectedId::change}}">
  <template is="dom-repeat" items="{{arrayItems}}" >
    <option value="{{item}}" id="{{item}}">{{item}}</option>
  </template>
</select>

https://jsfiddle.net/fiddle_gabriela/a58L52yh/2/

The selectedId represents the id of the item to be selected in the select box
(1 for the first element, 2 for the second, etc.).

At the creation of the select box I would like to select the 4th element in the list.
The problem is that selectedId gets the value of the element (e.g. admission, alert, ...) and not its id.

How to get the id instead of the value?

update expected result (from comment)

<select> 
  <option value="admission">admission</option> 
  <option value="alert">alert</option> 
  <option value="bvt_sample">bvt_sample</option> 
  <option value="clinicalpath" selected > clinicalpath</option> 
</select>
Günter Zöchbauer

You can use a function to check if the current item is the same as the one actually selected.

<option value="{{item}}" id="{{item}}" selected="{{isSelected(item)}}">
isSelected: function(item) {
  console.log(item);
    return item === this.selectedId;
}

https://jsfiddle.net/zkrb4jkz/

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Polymer - fail in implement a simple element

From Dev

Polymer select2 element

From Dev

Use native node name for a Polymer custom element?

From Dev

Polymer iron-select fires on element load

From Dev

Polymer, how to select element that is inside conditional template

From Dev

polymer 1.0 select element in dom-if template

From Dev

How to select first element in array in Polymer

From Dev

Polymer - Select DOM Element from if template

From Dev

Select element with Dart/Polymer: How to get index on-select

From Dev

Select element with Dart/Polymer: How to get index on-select

From Dev

How can I rewrite the native HTML input element with Polymer?

From Dev

How can I rewrite the native HTML input element with Polymer?

From Dev

Polymer: is possible to add <content> inside a select (native or extended) tag?

From Dev

How to create a <select> element with polymer-dart repeat

From Dev

Polymer and Disqus on Firefox: Argument 1 of Window.getComputedStyle does not implement interface Element

From Dev

clone of polymer element remove template of polymer element

From Dev

Polymer - Show element inside polymer element

From Dev

Trying to append a Polymer element in another Polymer element

From Dev

How to implement Drop Down Box that loads element on select?

From Dev

Polymer querySelector can't find custom polymer element in polymer element

From Dev

Polymer querySelector can't find custom polymer element in polymer element

From Dev

How to implement error tracking in a polymer?

From Dev

Get polymer parent element

From Dev

Selecting element (Polymer 1.0)

From Dev

Polymer property not in element

From Dev

Passing data to a Polymer element

From Dev

YUIDocs parse Polymer element

From Dev

Polymer - Updating Element

From Dev

Polymer array as member in element

Related Related

  1. 1

    Polymer - fail in implement a simple element

  2. 2

    Polymer select2 element

  3. 3

    Use native node name for a Polymer custom element?

  4. 4

    Polymer iron-select fires on element load

  5. 5

    Polymer, how to select element that is inside conditional template

  6. 6

    polymer 1.0 select element in dom-if template

  7. 7

    How to select first element in array in Polymer

  8. 8

    Polymer - Select DOM Element from if template

  9. 9

    Select element with Dart/Polymer: How to get index on-select

  10. 10

    Select element with Dart/Polymer: How to get index on-select

  11. 11

    How can I rewrite the native HTML input element with Polymer?

  12. 12

    How can I rewrite the native HTML input element with Polymer?

  13. 13

    Polymer: is possible to add <content> inside a select (native or extended) tag?

  14. 14

    How to create a <select> element with polymer-dart repeat

  15. 15

    Polymer and Disqus on Firefox: Argument 1 of Window.getComputedStyle does not implement interface Element

  16. 16

    clone of polymer element remove template of polymer element

  17. 17

    Polymer - Show element inside polymer element

  18. 18

    Trying to append a Polymer element in another Polymer element

  19. 19

    How to implement Drop Down Box that loads element on select?

  20. 20

    Polymer querySelector can't find custom polymer element in polymer element

  21. 21

    Polymer querySelector can't find custom polymer element in polymer element

  22. 22

    How to implement error tracking in a polymer?

  23. 23

    Get polymer parent element

  24. 24

    Selecting element (Polymer 1.0)

  25. 25

    Polymer property not in element

  26. 26

    Passing data to a Polymer element

  27. 27

    YUIDocs parse Polymer element

  28. 28

    Polymer - Updating Element

  29. 29

    Polymer array as member in element

HotTag

Archive