问题
my polymer element:
<ele-label id="newLabel" color="#000000" bgColor="#f1f1f1" eleHeight="30" eleWidth="50" text="Name:" eleDisplay="inline-block" elefloat="left"></ele-label>
but when I clone this element inner html will removed.
can any one help me ?
<polymer-element name="ele-label" attributes="text color eleid eleWidth eleHeight fontSize bgColor paddingTop paddingBottom paddingLeft paddingRight eleDisplay elefloat" > <template> <div><label style="font-size:{{fontSize}}pt; color:{{color}} ;">{{text}}</label></div> </template></polymer-element>
回答1:
finally got solution
polylabel1 : id of my div in side template of polymer element.
Polymer('ele-label', {
ready: function()
{
this.innerHTML=this.$.polylabel1.outerHTML;
}
attributeChanged: function()
{
this.innerHTML=this.$.polylabel1.outerHTML;
}
}
回答2:
When using the <template> tag in Polymer, it creates a shadow DOM, which is not part of the main DOM. You won't see the elements in the DOM itself, because it's not there. Take a look at the article i linked to learn more.
EDIT: It sounds like jQuery is not cloning the element's shadow with it. Try using .clone(true) to also clone related data.
来源:https://stackoverflow.com/questions/22680770/clone-of-polymer-element-remove-template-of-polymer-element