0

How to access to inside elements in the script part on the Polymer element?

Goce Ribeski
  • 1,352
  • 13
  • 30

1 Answers1

1

Here is example plnkr.co

<script>
      Polymer("my-element", {

       ready: function() {

              //access the input element by 'Change' event
              container_test = this.$.container; //correct one
             // or: var container_test  = this.shadowRoot.querySelector('#' + container);
             // from: http://stackoverflow.com/questions/24588708/polymer-automatic-node-finding-with-dynamic-id-value
              container_test.addEventListener('input', function(event) {

                  console.log('input event');
                  console.log(event);
                  console.log(event.target.tagName);
                  //console.log(event.target);
                  console.log(event.target.attributes.custom_attr.value);

            });
        },

        //access the input element by Declarative event mapping
        clickHandler: function(event) {
                  console.log('clickHandler event');
                  console.log(event);
                  console.log(event.target.tagName);
         },

    });
  </script>
Goce Ribeski
  • 1,352
  • 13
  • 30