admin管理员组文章数量:1289879
I have a polymer element which has a costum element inside it. I want to remove everything (parent and child) when I click on it.
The problem is that every time I close an instance of the parent element I get an error. I think it's related to the fact I'm removing an element that has an element inside.
How can I remove it correctly?
Here's the method code:
closeWindow: function (event, detail, sender) {
this.firstChild.remove();
this.remove();
}
Here's the error I'm having:
Uncaught TypeError: Cannot read property 'length' of undefined
Here's an image of the error:
I have a polymer element which has a costum element inside it. I want to remove everything (parent and child) when I click on it.
The problem is that every time I close an instance of the parent element I get an error. I think it's related to the fact I'm removing an element that has an element inside.
How can I remove it correctly?
Here's the method code:
closeWindow: function (event, detail, sender) {
this.firstChild.remove();
this.remove();
}
Here's the error I'm having:
Uncaught TypeError: Cannot read property 'length' of undefined
Here's an image of the error:
Share Improve this question edited May 17, 2014 at 20:01 APerson 8,4228 gold badges38 silver badges49 bronze badges asked May 17, 2014 at 19:54 iroyoiroyo 7637 silver badges25 bronze badges 4- Can you create a jsfiddle that shows off this behavior? – Peter Burns Commented May 17, 2014 at 23:36
-
What's wrong with just
this.remove()
? – ebidel Commented May 19, 2014 at 23:00 - Good news!! with the new release (0.2.4) this error seems to be solved – iroyo Commented May 23, 2014 at 14:43
- 1 Interesting, I have a same problem. It doesn't seem to me that it has been resolved. – Aero Wang Commented Feb 27, 2015 at 15:23
2 Answers
Reset to default 7This issue was fixed a few releases ago and should also work fine in Polymer 0.3.x onwards. If you run into any further issues with this.remove()
within the scope of an element, please file an issue.
On polymer 1.5.0+
you do event.target.remove()
本文标签: javascriptPolymer Correctly remove polymer element whith elements inside itStack Overflow
版权声明:本文标题:javascript - Polymer: Correctly remove polymer element whith elements inside it - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741444971a2379141.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论