Instantiating Web Components from JS

38 views
Skip to first unread message

javier.ve...@gmail.com

unread,
Mar 5, 2014, 1:48:48 PM3/5/14
to polym...@googlegroups.com
Hi,

I am trying to instantiate web components directly from Javascript but the system does not find the public constructor. I'll put a simple example to show the context and the results:

HTML Template:

<polymer-element name="wc-foo" constructor="Foo" noscript>
    <template>
       Hello World!
    </template>  
</polymer-element>

HTML index:

<html>
<head>
    <script src="general/scripts/polymer/polymer.min.js"></script>
    <link rel="import" href="...">
</head>

<body>
</body>
 
<script>
console.log (window); // (1)
console.log (window.Foo); // (2)
var foo = new Foo (); // (3)
</script>

</html>

Console Results:

(1) I have checked the window object and it includes the constructor Foofunction (){return f(a)}
(2) I don't know what but window.Foo returns undefined
(3) ...And so, new Foo() fails: Uncaught ReferenceError: Foo is not defined

Someone can help me to understand whats is the problem?
Thanks.

Alex Komoroske

unread,
Mar 5, 2014, 1:54:01 PM3/5/14
to javier.ve...@gmail.com, polym...@googlegroups.com
Can you ask this on stackoverflow with a polymer tag so we can answer there? I bet other people in the future will be interested in the answer.


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/8f1d8146-32d0-4ab6-9642-508abdcf75fb%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply all
Reply to author
Forward
0 new messages