javascript - How to bind paper-toggle-button state to its label - Polymer -


i have several paper-toggle-button elements receive checked state via iron-ajax get, bringing json data of true/false nature set toggles on/off respectively.

i have labels next buttons display toggled state also, these taking same data toggles themselves. however, change labels bound current state of toggle rather back-end json data.

is @ possible?

html

<paper-toggle-button id="approver"  checked$="{{current.approver}}">{{current.approver}}</paper-toggle-button> <paper-toggle-button id="askexpert"  checked$="{{current.askexpert}}">{{current.askexpert}}</paper-toggle-button> <paper-toggle-button id="autoconnect"  checked$="{{current.autoconnect}}">null{{current.autoconnect}}</paper-toggle-button> <paper-toggle-button id="beexpert"  checked$="{{current.beexpert}}">{{current.beexpert}}</paper-toggle-button> 

you're using attribute binding checked (i.e., checked$="{{flag}}"), checked property, should use property binding (i.e., checked="{{flag}}") proper data-binding notifications. note removed $ binding:

<paper-toggle-button id="approver"  checked="{{current.approver}}">{{current.approver}}</paper-toggle-button> <paper-toggle-button id="askexpert"  checked="{{current.askexpert}}">{{current.askexpert}}</paper-toggle-button> <paper-toggle-button id="autoconnect"  checked="{{current.autoconnect}}">{{current.autoconnect}}</paper-toggle-button> <paper-toggle-button id="beexpert"  checked="{{current.beexpert}}">{{current.beexpert}}</paper-toggle-button> 

demo

i believe behavior you're seeking achieved fixing binding type indicated above.


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -