在Safari或Firefox

时间:2016-06-20 17:09:20

标签: polymer polymer-1.0 paper-dialog

尝试在单击纸张按钮时打开此纸张对话框,但似乎不想在Chrome外部工作。我觉得这个问题与它是一个重复的事实有关,但我不确定你能给我的任何帮助将不胜感激。我在Safari中遇到的错误是“TypeError:dialog1.toggle()不是函数。”在'dialog1.toggle()'中,'dialog1.toggle'未定义)“。在Firefox中,我刚刚得到“TypeError:dialog1.toggle不是函数”。这是我的代码,我希望有人可以指出我正确的方向。

<script src="../bower_components/webcomponentsjs/webcomponents.js"></script>
<link rel="import" href="../bower_components/iron-ajax/iron-ajax.html">
<link rel="import" href="../bower_components/polymer/polymer.html">
<link rel="import" href="../bower_components/paper-item/paper-item.html">
<link rel="import" href="../bower_components/paper-button/paper-button.html">
<link rel="import" href="../bower_components/paper-dialog/paper-dialog.html">
<link rel="import" href="../bower_components/paper-dialog-behavior/paper-dialog-behavior.html">
<link rel="import" href="../bower_components/paper-dialog-behavior/demo/simple-dialog.html">
<link rel="import" href="../bower_components/paper-dropdown-menu/paper-dropdown-menu.html">
<link rel="import" href="../bower_components/paper-listbox/paper-listbox.html">
<link rel="import" href="../bower_components/paper-dialog-scrollable/paper-dialog-scrollable.html">
<link rel="import" href="../bower_components/iron-demo-helpers/demo-snippet.html">
<link rel="import" href="../bower_components/iron-demo-helpers/demo-pages-shared-styles.html">
</head>
<body class="unresolved">


<template is="dom-bind">
<template is="dom-repeat" items="{{data}}">
<paper-button raised onclick$="dialog{{item.id}}.toggle()">{{item.series}}  </paper-button>
  <simple-dialog id$="dialog{{item.id}}">
    <h2>{{item.series}}</h2>
    <p>{{item.data}}</p>
  </simple-dialog>
<br />
</template>
<iron-ajax auto id="GetData" url="get_category_data.php" handle-as="json" last-response="{{data}}" ></iron-ajax>
</template>

</body>

2 个答案:

答案 0 :(得分:1)

使用getElementById似乎工作正常。这是在firefox中为我工作的代码。希望它也适用于野生动物园

<template is="dom-bind">
 <template is="dom-repeat" items="{{data}}">
  <paper-button raised onclick$="toggleDialog({{item.id}})">{{item.series}}</paper-button>
  <simple-dialog id$="dialog{{item.id}}">
   <h2>{{item.series}}</h2>
   <p>{{item.data}}</p>
  </simple-dialog>
  <br />
 </template>
 <iron-ajax auto id="GetData" url="get_category_data.json" handle-as="json" last-response="{{data}}" ></iron-ajax>
</template>
<script>
 function toggleDialog(id){
  var dialog = document.getElementById('dialog'+id);
  dialog.toggle();
 }
</script>

答案 1 :(得分:1)

旧线程,但我将为Polymer1.0

添加上述变体
<div>
    VAT check date: <paper-button value="paperbuttontest" raised on-tap="_paperDialogButtonEdit">{{buyer1.vat_check_date}}</paper-button>
    <paper-dialog id="vat_check_date_dialog_edit">
         <calendar-lite name="date.buyer1.vat_check_date" min-date="2017,3,1"></calendar-lite>
    </paper-dialog>
</div>

和聚合物

_paperDialogButtonEdit: function (event) {
//console.log(" event.target = ",event.target.getAttribute('value'));
var dialog = document.getElementById('vat_check_date_dialog_edit');
dialog.toggle();
},