clone of polymer element remove template of polymer element

我是研究僧i 提交于 2019-12-05 22:03:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!