Polymer: can not found the elements by this.$.XXX which inside the dom-if

Created on 3 Jun 2016  路  4Comments  路  Source: Polymer/polymer

Description

Live Demo

https://jsbin.com/xukike/edit?html,output

Steps to Reproduce

Actual Results

Browsers Affected

  • [x] Chrome
  • [ ] Firefox
  • [ ] Edge
  • [ ] Safari 9
  • [ ] Safari 8
  • [ ] IE 11

Versions

  • Polymer: vX.X.X
  • webcomponents: vX.X.X
1.x

Most helpful comment

This is a limitation of creation of the this.$ hash as described here: https://www.polymer-project.org/1.0/docs/devguide/local-dom#node-finding

Note: Nodes created dynamically using data binding (including those in dom-repeat and dom-iftemplates) are not added to the this.$ hash. The hash includes only statically created local DOM nodes (that is, the nodes defined in the element's outermost template).

All 4 comments

@hzmnet You need to use this.$$('#<id>') to find elements that generate dynamically.

Your issue and your jsbin are not very explicit.
Could you please give us a better example and more explanation about your problem?

If you want to find an element with its id you need to use this.$.<id>.
If you want to find an element with its name you need to use this.$$.('element-name').
You can also use Polymer DOM API to find an element through the shadow DOM.

I hope this answer will help you, if not I would be pleased to discuss with you about it if you give us more details.

This is a limitation of creation of the this.$ hash as described here: https://www.polymer-project.org/1.0/docs/devguide/local-dom#node-finding

Note: Nodes created dynamically using data binding (including those in dom-repeat and dom-iftemplates) are not added to the this.$ hash. The hash includes only statically created local DOM nodes (that is, the nodes defined in the element's outermost template).

Closing per above comment.

Was this page helpful?
0 / 5 - 0 ratings