Reputation: 6547
I am building a polymer element hosting frame, where the user can configure what item they want to be hosted inside the outerframe with header. For instance if the content is set to 'paper-button' the host will display the button with toolbar. Where do I add the appendChild code, it doesn't work on ready
or attached
event?
<dom-module id="element-host">
<template>
<paper-header-panel>
<paper-toolbar>Header</paper-toolbar>
<content id="content"></content>
</paper-header-panel>
</template>
<script>
Polymer({
is: 'element-host',
properties: {
content : {
type: string
}
},
attached: function(renderer) {
var customElement = document.createElement(this.content);
this.$.content.appendChild(customElement);
}
});
</script>
</dom-module>
Upvotes: 1
Views: 3739
Reputation: 11
Check out Polymer's selector. For locating dynamically-created nodes in your element’s local DOM, use the $$ method:
this.$$(selector)
Upvotes: -1
Reputation: 657068
You can get the dom
of Polymer
by passing this
and call the appendChild
of the result, passing customElement
:
Polymer.dom(this).appendChild(customElement);
Upvotes: 4