Closed PatrickMcLennan closed 4 years ago
SubmitEvent
only exists in stdweb
. If you're using web-sys
the appropriate type is FocusEvent
. See GlobalEventHandlers.onsubmit
.
The event type is the same as the Javascript type in most cases when using web-sys
.
We'll hopefully have better documentation for the event types soon (#1450)
yew.rs
yet). Closing this.Thanks for the answer / clarification @siku2 .
I ran into this same "misunderstanding" today. I'm confused because it seems to me that the event generated by submitting a form has little if anything to do with focus. The GlobalEventHandlers.onsubmit
MDN documentation doesn't mention "focus", however it might just be something a more experienced web developer would associate intuitively. I'd really appreciate a bit more info on the subject. Thanks!
@rhymu8354 even as a FE web developer by trade it didn't dawn on me to associate the 2 events either. Submit and focus events are separate and do separate things. In any FE library or framework I've used, in this scenario you'd be dealing solely with the submit event. Speaking candidly I'm not so sure this would be intuitive to most but I'll also admit to being far more junior with rust and the wasm ecosystem than I am with more "standard" html form handlers, so, this could be more intuitive to a rust/yew developer than I give it credit for.
Regardless this seems to be more of an issue with web-sys than yew, but I agree that if their docs still don't cover this it would be helpful.
Question
I need to get the SubmitEvent in order to perform a
preventDefault
Following the docs here, I would assume that...use yew::events::SubmitEvent
would work, and it does not. Where can I find this struct in order to define it properly?
What I've tried (optional)
use yew::events::SubmitEvent
use yew::events::{SubmitEvent}
use yew::SubmitEvent
and a million other goofy things out of desperation.Each time, I get hit with some variant of "no SubmitEvent in ____".
Am I doing something wrong? I can't find this struct anywhere, and Rust won't compile without me defining, pictured below.