I am trying to retrieve updated data in a child Polymer element, but the data stays bound to the initialized value.
PARENT
<template is="dom-if" if="[[items.0]]">
<child-el id="id_0" id-item="[[items.0.idItem]]"></child-el>
</template>
...
_updateChild () {
if (this.items[0]) {
this.shadowRoot.getElementById('id_0').idItem = this.items[0].idItem;
this.shadowRoot.getElementById('id_0').idItem.notifyPath;
}
}
CHILD
<iron-ajax id="ajax"
handle-as="json"
last-response="{{data}}"
method="get"
on-error="_onError"
url="https://api.com/item-price">
</iron-ajax>
<div>
<p id="price">[[price(data.price)]]</p>
</div>
...
static get properties() {
return {
idItem: { type: String, observer: 'getResponse' }
}
}
getResponse() {
let request = this.$.ajax.generateRequest();
request.completes.then(req => {
this.idItem = null;
})
}
price(amt) {
return amt
}
Update pricing executes, but when idItem
is set, but the observer on idItem
"getResponse()
" doesn't execute and bind to data.price
.
How can I get these events to cascade properly so each time items.0.idItem
changes the binding on the child-eel
this.data.price
gets updated?
How is the items.0.idItem changed?
Try changing the idItem like this
this.set('items.0.idItem', 100)