我有一个对象数组,4个对象,每个对象包含7个数据持有者。一些数据用于设置Polymer 0.9中的元素样式,相应的数据在AJAX调用时更改,但它们不更新元素的样式...
变量声明:
info: {
type: Array,
notify: true,
value: [
{ centar: "color: #9E9E9E;", *SOME OBJECTS* },
{ centar: "color: #9E9E9E;", *SOME OBJECTS* },
{ centar: "color: #9E9E9E;", *SOME OBJECTS* },
{ centar: "color: #9E9E9E;", *SOME OBJECTS* },
]
}
JS:
infoLoaded: function(e){
this.infoRAW = e.detail.response;
for (i = 0; i < this.infoRAW.length; i++) {
this.info[i].centar = this.centarColor(this.infoRAW[i].skicentar.toLowerCase());
this.info[i].brojstaza = this.infoRAW[i].brojstaza;
this.info[i].temperatura = this.infoRAW[i].temperatura;
this.info[i].vrijeme = this.infoRAW[i].vrijeme;
}
}
HTML:
<template is="dom-repeat" items="{{info}}">
<paper-material z="1" class="chip" hero-id="{{item.planina}}" hero?="{{selectedPlanina === item}}">
<div class="chip-top" style$="{{item.color}}" hero-id="{{item.planina}}-art" hero?="{{selectedPlanina === planina}}"></div>
<div class="chip-bottom">
<div class="chip-planina">{{item.planina}}</div>
<div class="chip-centar">Centar <i class="fa fa-circle" style$="{{info.centar}}"></i></div>
</div>
</paper-material>
{1}}在ajax完成时不会更改,但style$="{{info.centar}}"
上的控制台登录显示该值已更改..
帮助?
编辑#1
我修好了!对于为数组分配值并将它们用作动态的任何人,而不是使用:
this.info.centar
使用:
this.info[i].brojstaza = this.infoRAW[i].brojstaza;