Everything about propagation can be done by binding. So something like
<iron-pages>
<1-0 selected="{{selectedOne}}"></1-0>
<2-0 selected="{{selectedTwo}}"></2-0>
</iron-pages>
inside son elements you define property: selected
. and set them notify: true
. Notify means that whenever this property changes, parent element property binded to this value will update automatically.
properties: {
selected: {
value: null,
notify: true
}
}
inside son elements your iron-pages
must have binding to selected
property.
Like:
<iron-pages selected="{{selected}}">
and that's it. Whenever selected property changes (inside son elements), parent element will automatically reload his selectedOne
and selectedTwo
properties.
You can also add observer to selectedOne
and selectedTwo
properties, which will call some function so you know exactly when to do some logic.
so in mother element:
properties: {
selectedOne: {
value: null,
observer: "_selectedOneChanged"
},
selectedTwo: {
value: null,
observer: "_selectedTwoChanged"
}
}
Another solution
Solution above is good but in more nested elements it's almost impossible to make it work and it's really messy. So another way would be event listener. Polymer has fire method which is really great to know. More info you can find in documentation.
Briefly:
in son element you do something like
this.fire("iron-pages-changed", {page: this.selected});
and mother element:
ready: function() {
this.addEventListener("iron-pages-changed", function() {
... some logic ...
}
}