在Polymer组件中显示对话框

时间:2015-04-01 13:10:02

标签: javascript jquery dialog polymer web-component

我是一个聚合物组件,从其中一个功能内部我想向用户显示一个对话框。 我尝试使用dialog-paper,如下所示:

<template>
  <link rel="stylesheet" href="../themes/the-graph-dark.css">
  <link rel="stylesheet" href="../themes/the-graph-light.css">
  <div id="svgcontainer"></div>
  <paper-dialog heading="Title for dialog" id="dialog">
    <p>Lorem ipsum ....</p>
    <p>Id qui scripta ...</p>
    <paper-button label="More Info..." dismissive></paper-button>
    <paper-button label="Decline" affirmative></paper-button>
    <paper-button label="Accept" affirmative autofocus></paper-button>
  </paper-dialog>
</template>
...
eventHandler: function(event) {
  this.$.dialog.toggle();
  console.log(event);
},    

当我在调用eventHandler时尝试切换对话框时,没有显示任何内容,我得到Uncaught TypeError: undefined is not a function

在组件中显示对话框的适当方法是什么?

1 个答案:

答案 0 :(得分:0)

像这样

Polymer({
  that: this,
  ready: function(){
      addEventListener('on-blabla-event', function(event){
        that.$.dialog.toggle();
        console.log(event);
      });
    }
});