Skip to content

how to get inner element #280

Description

@icode
    <polymer-element name="ui-download-percentage">
        <template>
            <style>
                @host {
                    ui-download-percentage {

                    }
                }
            </style>
            <svg width="100%" height="100%" version="1.1" xmlns="http://www.w3.org/2000/svg">
                <path transform="matrix(1,0,0,1,-28,96)"/>
            </svg>
        </template>
        <script>
            Polymer('ui-download-percentage', {
                enteredDocument: function () {
                    var pathEl = this.impl.querySelector('svg>path');
                }
            });
        </script>
    </polymer-element>

like this? how to get template generate element?
what's enteredDocument callback ?

Activity

  1. ebidel commented on Sep 17, 2013

    @ebidel
    Contributor

    This is a great question for stack overflow :) Closing this as it's not a request/bug. report


    To answer your question, the best way is to add an id to <path> and reference it that way:

     <path id="path" transform="matrix(1,0,0,1,-28,96)"/>
     ....
     enteredDocument: function () {
        var pathEl = this.$.path
      }
    

    Full example: http://jsbin.com/arumUq/3/edit

    enteredDocument (now enteredView maps to the custom element lifecycle callback, enteredViewCallback:
    http://www.polymer-project.org/polymer.html#lifecyclemethods

    For your case, you can stick with the created callback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions