How to programmatically create and bind polymer elements ?

1,222 views
Skip to first unread message

wessel...@gmail.com

unread,
Sep 22, 2014, 5:59:43 PM9/22/14
to polym...@googlegroups.com
Hi

I am going to write some more complicated elements like grids that have dynamically created cells with polymer elements in each cell based on the cell type.

To do that I need to create and bind polymer elements programmatically during runtime.

I cannot find any documentation about that.

Is it possible?

How?

Any risks/limitations with polyfills/life cycle/memory leaks?

Thank you
Bernd

Michael Bleigh

unread,
Sep 22, 2014, 6:03:52 PM9/22/14
to polym...@googlegroups.com, wessel...@gmail.com
Are you looking to instantiate existing elements or register new ones on the fly? If you're just looking to create elements you've already defined, you can just use standard DOM APIs!

var node = document.createElement("my-custom-element");
node
.someProperty = "someValue";
this.appendChild(node)


If you're looking to define new ones on the fly, I'm not 100% sure why you'd want to and I'm also not 100% how, so I'll let someone else handle that.

Eric Bidelman

unread,
Sep 22, 2014, 6:09:42 PM9/22/14
to Michael Bleigh, polymer-dev, wessel...@gmail.com

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/50624710-e235-46c1-b504-ea75cd5c503c%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

wessel...@gmail.com

unread,
Sep 22, 2014, 9:32:41 PM9/22/14
to polym...@googlegroups.com, mbl...@gmail.com, wessel...@gmail.com
Thank you

Looks interesting. I will give it a try.

Without documentation I am a bit concerned that I might miss memory leaks or problems with polyfills on IE, but seems to be a good starting point.

Hopefully documentation around polymer will become better. Sometimes it is a bit frustrating to find stuff - and Dart overshadows a lot of polymer - which makes it even harder for JavaScript Polymer developers to find anything.

Cheers
Bernd

ihab...@gmail.com

unread,
Aug 18, 2015, 7:40:05 PM8/18/15
to Polymer, mbl...@gmail.com, wessel...@gmail.com
Is this supported in Polymer 1.0? I can't find it anywhere. Is there an alternative?

Ihab
Reply all
Reply to author
Forward
0 new messages