Search code examples
javascriptpolymerweb-componentpolymer-starter-kit

how can i use a Polymer element after instantiating it?


For example

var todopopup = new TodoPopup(); todopopup.open();

will this work??

Hello world

</template>
<script>
TodoPopup = Polymer({
        is : 'todo-popup' ,
        behaviors : [Polymer.IronOverlayBehavior]
    });
</script>


Solution

  • You create a new instance imperatively like

    var todopupup = document.createElement('todo-popup');
    

    See also https://www.polymer-project.org/1.0/docs/devguide/registering-elements

    You can attach it somewhere.

    document.body.appendChild(todopupup);
    todopopup.open();