I'm trying to use a Polymer paper-dialog to display a message in response to an external event and am having difficulty even with a simple case. I'm getting an error saying 'this.$: undefined' (see code below).
<link rel="import" href="bower_components/polymer/polymer.html">
<link rel="import" href="bower_components/paper-dialog/paper-dialog.html">
<dom-module id="dialogtest-main">
<template>
<paper-dialog id='goodbyeDialog' modal>
<p> Goodbye! </p>
<div class='buttons'>
<paper-button dialog-dismiss>Cancel</paper-button>
</div>
</paper-dialog>
<p align="center">Hello...</p>
</template>
<script>
doTimer = function() {
element.openDialog();
}
element = {
is: "dialogtest-main",
ready: function() {
window.setTimeout(doTimer, 1000);
console.log("ready");
},
openDialog: function() {
console.log("opening dialog");
this.$.goodbyeDialog.open();
}
};
Polymer(element);
</script>
</dom-module>
I have made a few desperate stabs by placing a breakpoint in the openDialog function and executing in the console:
this.$
undefined
this.$.goodbyeDialog
TypeError: this.$ is undefined
element.$.goodbyeDialog
TypeError: element.$ is undefined
document.getElementById("goodbyeDialog")
< paper-dialog modal="" id="goodbyeDialog" class="style-scope dialogtest-main x-scope paper-dialog-0" role="dialog" tabindex="-1" aria-hidden="true" aria-modal="true" style="outline: medium none; display: none;">
document.getElementById("goodbyeDialog").open()
undefined
document.getElementById("goodbyeDialog").toggle()
undefined
Any ideas? I'm sure I must be doing something very simple wrong!
window.setTimeout
, why not directly callthis.openDialog()
from eitherready
event orattached
? – SG_