Is there an equivalent "polymer" event in Polymer 1.0?

I need to know when I start using my custom Polymer elements programmatically. The items are still undefined

even in my handler window.onload

. Is there an established way to do this correctly with Polymer 1.0?

-Edit -

I can see there is a downline, so let me clarify this issue. I have the following custom element definition:

<link rel="import" href="../../bower_components/polymer/polymer.html">

<dom-module id="element-one">
    <style>
        :host { display: block; background-color: blue; }
    </style>
    <template>
        <h1>Element One</h1>
        <content></content>
    </template>
</dom-module>

<script>
var ElementOne = Polymer({
    is: "element-one"
});
</script>

      

Then I import this into mine index.html

:

<link rel="import" href="elements/element-one/element-one.html">

      

And at the bottom index.html

, before the tag </body>

, I'm trying to instantiate the element ElementOne

:

<script>
    console.log(typeof ElementOne); // undefined
    var el = new ElementOne(); // fails, obviously

    // try on window load
    window.onload = function () {
        console.log(typeof ElementOne); // undefined
    };
</script>

      

I should note that this problem occurs in recent versions of Firefox and IE 10/11, but not in Chrome.

+3


source to share


1 answer


use WebComponentsReady event:



window.addEventListener('WebComponentsReady', function(e) {
...
});

      

+14


source







All Articles