Closed EstebanBorai closed 1 year ago
Thanks, but this is already possible:
html!("select" => HtmlSelectElement, {
.with_node!(element => {
.event(move |_: events::Change| {
let value = element.value();
// ...
})
})
})
You can access any of the methods on the underlying DOM type by using with_node!
Thanks, but this is already possible:
html!("select" => HtmlSelectElement, { .with_node!(element => { .event(move |_: events::Change| { let value = element.value(); // ... }) }) })
You can access any of the methods on the underlying DOM type by using
with_node!
Hi @Pauan thanks for the quick prompt!
Yeah! In my use case I'm exposing the Change
struct which impl
I'm extending.
But I found a way around it.
If you consider this PR is not necessary I could close it.
Thanks!
Yeah! In my use case I'm exposing the Change struct which impl I'm extending.
Why are you doing that?
Yeah! In my use case I'm exposing the Change struct which impl I'm extending.
Why are you doing that?
In my codebase I have a handler on the change
event which takes the event and creates an instance of this Change
struct we are talking about.
Okay, but I'm still not sure why you're doing that. What are you trying to accomplish?
Okay, but I'm still not sure why you're doing that. What are you trying to accomplish?
Access the element value
based on the previous premise.
Given that I only have access for such Change
struct addressed in the PR, I wanted to expose the value
attribute value by adding the method introduced here.
But why are you creating a new Change
struct at all? Why not just pass in the value directly?
html!("select" => HtmlSelectElement, {
.with_node!(element => {
.event(move |_: events::Change| {
state.some_method(element.value());
})
})
})
But why are you creating a new
Change
struct at all? Why not just pass in the value directly?html!("select" => HtmlSelectElement, { .with_node!(element => { .event(move |_: events::Change| { state.some_method(element.value()); }) }) })
Hi @Pauan, I'm not the author of the crate so I'm not sure why the API is implemented like this. I will close this PR as theres clearly a solution already for what I purpose here.
Thanks for your time an patience and of course for such a great crate!
Oh, interesting, I'm curious which crate you are using. Is it MoonZoon? I think they have a different way of accessing DOM nodes.
Introduces support to retrieve the
value
from HTMLInputElements which value isString
compatible andHTMLSelectElement
in order to retrieve selected option values.