You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Say we have some object btn with property isOn.
User navigates to a page, that renders the switch; the <input> element is rendered by backend, that sets the checked=checked attribute because this btn instance has isOn=true.
Switch uses the attribute correctly and the button is initialised in ON state as expected.
Now user navigates away, btn.isOn is set to false by some event, and then goes history.back().
Caching is off and the html is re-rendered. Server sends the <input> element without the checked attribute as expected. But the switch is still in ON state; supposedly because the checkbox has checked property (not attr) set.
What's the correct way for solving such scenarios? So far I've been setting the state manually from the init block like this:
Say we have some object
btn
with propertyisOn
.User navigates to a page, that renders the switch; the
<input>
element is rendered by backend, that sets thechecked=checked
attribute because thisbtn
instance hasisOn=true
.Switch uses the attribute correctly and the button is initialised in ON state as expected.
Now user navigates away,
btn.isOn
is set tofalse
by some event, and then goes history.back().Caching is off and the html is re-rendered. Server sends the
<input>
element without thechecked
attribute as expected. But the switch is still in ON state; supposedly because the checkbox haschecked
property (not attr) set.What's the correct way for solving such scenarios? So far I've been setting the state manually from the init block like this:
But it feels like there should be something better.
Reproduced with firefox & chromium running on a linux box.
The text was updated successfully, but these errors were encountered: