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>
i believe behavior you're seeking achieved fixing binding type indicated above.
Comments
Post a Comment