-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
checkbox re-render is forever checked #405
Comments
Thanks for the report. madness* - copy/paste from Elm docs:
or copy/paste from Vaadin docs:
|
In case anyone else comes across this and needs some guidance. My use case is I have a:
and I've made the outer span clickable, so in the view, when I grab the click event, I toggle the checkbox, as well as sending my Msg to update the model:
I should probably do the actual change in the update. I don't really know what I'm doing, but I'm hacking my way through :) Machete programming. |
Standard way (should work on released Seed versions): span![
input![
attrs!{At::Type => "checkbox"},
attrs!{At::Checked => model.checked.as_at_value()}
],
"bunch of other stuff",
ev(Ev::Click, |_| Msg::Toggle)
] Alternative way with direct DOM manipulation (not recommended): span![
input![
el_ref(&model.my_checkbox),
attrs!{At::Type => "checkbox"},
],
"bunch of other stuff",
ev(Ev::Click, {
let my_checkbox = model.my_checkbox.clone();
move |_| {
let my_checkbox = my_checkbox.get().expect("my_checkbox DOM element");
let checked = my_checkbox.checked();
my_checkbox.set_checked(not(checked));
Msg::Toggle
}
})
] Future way span![
input![
A.type_().checkbox(),
A.checked(model.checked),
],
"bunch of other stuff",
E.click(|_| Msg::Toggle),
] |
Thank you Martin, that has moved me forward. What about "indeterminate" state ? https://css-tricks.com/indeterminate-checkboxes/ I'm guessing at the moment, the only way will be with direct DOM manipulation or JS ? |
I suggest to continue on https://seed.discourse.group/ |
If you render a
input![attrs!["type" => "checkbox", "checked" => "checked"]]
then after some event, re-render it without the the"checked" => "checked"
it looks good in the DOM inspector, but on the screen it's still checked.To get around it, I guess I have to give every checkbox an ID and call JS to uncheck it.
tested in brave browser, which is chrome based.
The text was updated successfully, but these errors were encountered: