【问题标题】:Vaadin combobox value-changed not workingVaadin 组合框值更改不起作用
【发布时间】:2016-05-31 19:16:07
【问题描述】:

我是 Polymer 的新手,我正在尝试使用 vaadin' 组合框构建应用程序,但从未触发 value-changed 事件...

在我的 html 中,我有:

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

<link rel="import" href="../../bower_components/vaadin-combo-box/vaadin-combo-box.html">

<link rel="import" href="../../bower_components/iron-ajax/iron-ajax.html">

<dom-module id="fast-purchase-data">
<template>
<iron-ajax id="placesListAjax"  url="../mock-responses/places.json" last-response="{{places}}"></iron-ajax>
<vaadin-combo-box value-changed="valueChange" label="Places" class="combobox elements-box" items="[[places.data.elements]]" item-label-path="name"></vaadin-combo-box>
<iron-ajax id="eventsListAjax"  url="../mock-responses/events-list.json" last-response="{{resp}}" auto></iron-ajax>
<vaadin-combo-box value-changed="valueChange" label="Events" class="combobox" items="[[resp.data.elements]]" item-label-path="name"></vaadin-combo-box>
</template>

<script>


(function() {
'use strict';

Polymer({
is: 'fast-purchase-data',

valueChange: function(ev, i){
console.log("hey");
},
_pageChanged: function() {
this.$.placesListAjax.generateRequest();
},
});
})();
</script>
</dom-module>

我可以在我的组合框中看到数据,但是当我更改它的值时,我看不到 console.log 也没有错误。我错过了什么?

【问题讨论】:

    标签: combobox polymer vaadin


    【解决方案1】:

    以声明方式添加事件侦听器的正确方法是使用on-event-name (docs)。 所以在你的情况下应该如下。

    <vaadin-combo-box on-value-changed="valueChange" ></vaadin-combo-box>
    

    【讨论】:

    • 非常感谢:)))
    • 你知道我是否/如何可以将键用作 vaadin 中的“项目”吗?类似&lt;vaadin-combo-box items="[[Object.keys(dates)]]"&gt;
    • 这应该可以,如果您将呼叫转移到 Object.keyscomputed binding
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-04-07
    • 1970-01-01
    相关资源
    最近更新 更多