[SO x-post] Polymer elements don't work, when loaded by XHR

105 views
Skip to first unread message

dzh...@gmail.com

unread,
Mar 31, 2015, 8:15:42 PM3/31/15
to polym...@googlegroups.com
Hello,

can anybody help me with problem http://stackoverflow.com/questions/29308986 ?

I posted the question to SO several days ago, but got no answers.

Thanks

Eric Eslinger

unread,
Mar 31, 2015, 8:23:13 PM3/31/15
to dzh...@gmail.com, polym...@googlegroups.com
I know that I have been able to insert polymer elements into the DOM  pretty easily, but I declared all the element types at start time. As a matter of fact, I kind of thought that all the link rel imports had to be in the document head. I'd try that part first, to see if it's the item declaration that's the problem or the injectoin.

e

Follow Polymer on Google+: plus.google.com/107187849809354688692
---
You received this message because you are subscribed to the Google Groups "Polymer" group.
To unsubscribe from this group and stop receiving emails from it, send an email to polymer-dev...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/polymer-dev/cc4a07d8-ec0c-4e4b-82b1-0b14eb31c8cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Pavel Sergeev

unread,
Apr 1, 2015, 8:50:22 PM4/1/15
to Eric Eslinger, polym...@googlegroups.com
Importing "paper-button" in a <head> of index.html doesn't help.
BTW, a live demo of my example can be found here http://dzhioev.net:8000/

Elliott Sprehn

unread,
Apr 2, 2015, 12:25:04 AM4/2/15
to Pavel Sergeev, Eric Eslinger, polymer-dev
This doesn't work because you're taking elements from an xhr document where there's no custom element registry and then just moving them. You need to do appendChild(document.importNode(response.body.children[0])) which will create a clone of the node, but using the document where polymer has registered the custom elements.

Eric Eslinger

unread,
Apr 2, 2015, 3:04:22 PM4/2/15
to Elliott Sprehn, Pavel Sergeev, polymer-dev
Ah yeah, that makes sense. I only ever dynamically add polymer elements by doing a document.createElement and then appendChild it.

Pavel Sergeev

unread,
Apr 2, 2015, 6:29:15 PM4/2/15
to Elliott Sprehn, Eric Eslinger, polymer-dev
Thanks, works like a charm!
Reply all
Reply to author
Forward
0 new messages