Here is example of the issue: Plunk
The initial value, 31, is not binding when changing the slider. Array value 31 is seated on the initiation, but can not be reseated after change.
How to properly bind slider to the array?
<base href="http://polygit.org/polymer+:master/components/">
<script src="webcomponentsjs/webcomponents-lite.min.js"></script>
<link href="polymer/polymer.html" rel="import">
<link href="paper-input/paper-input.html" rel="import">
<link href="paper-slider/paper-slider.html" rel="import">
<link href="google-chart/google-chart.html" rel="import">
<dom-module id="dynamic-chart">
<template>
Binded values:
<br>
arrayItem: {{arrayItem(rows.*, 0, 1)}}
<br>
arrayBase: {{arrayBase(rows.*)}}
<hr>
Jan slider:
<paper-slider min="1"
max="31"
value="{{rows.0.1}}"
pin
editable>
</paper-slider>
</template>
<script>
Polymer({
is: 'dynamic-chart',
properties: {
rows: {
type: Array,
notify: true,
},
},
//domReady:
attached: function() {
this.async(function() {
this.rows=[ ["Jan", 31],["Feb", 28],["Mar", 31] ];
console.log('domReady');
});
},
// first argument is the change record for the array change,
// change.base is the array specified in the binding
arrayItem: function(change, index, path) {
console.log('arrayItem');
return this.get(path, change.base[index]);
},
arrayBase: function(change) {
console.log('arrayBase');
return change.base;
},
});
</script>
</dom-module>
<dynamic-chart>
</dynamic-chart>
Update: array-selector (simple example) element can be used for this task too.
You are trying to bind your array first element
rows.0.1
which is a constant value,31
to thevalue
of the paper-slider. What is happening that thearrayItem
get notifies when its value change i.e!== 31
.What you should do is to bind the
max
value like this. PlunkrIt will be better to have your rows as object instead of Array of objects,this way: