Gert Cuykens
Gert Cuykens

Reputation: 7175

polymer-ready event is not ready yet?

When I try document.querySelector('core-drawer-panel').togglePanel() in the console it works but when I do the following core-drawer-panel is not ready yet?

<template>
    <core-drawer-panel forceNarrow>
    </core-drawer-panel>
</template>

<script>
        document.addEventListener('polymer-ready', function() {
            document.querySelector('core-drawer-panel').togglePanel()
            console.log('polymer-ready');
        });
</script>

Note that I can not wrap it in a polymer element due to issues with other js frameworks.

Upvotes: 0

Views: 662

Answers (1)

jimi dough10
jimi dough10

Reputation: 2016

try this

var template = document.querySelector('template');
template.addEventListener('template-bound', function () {
    //code
});

with your element inside a template you need to look for template to be ready not polymer.

Upvotes: 4

Related Questions