DOC: Add note about form prevent_default behavior. (#1343)
* Add note about form prevent_default behavior. * Make the default behavior clear on forms with attached event handlers.
This commit is contained in:
1 parent
bcebaafb5d
commit
8946944d68
2 files changed
+4
No files matched your search
@@ -51,6 +51,8 @@ Any event handlers will still be called.
|
||||
|
||||
> Normally, in React or JavaScript, you'd call "preventDefault" on the event in the callback. Dioxus does _not_ currently support this behavior. Note: this means you cannot conditionally prevent default behavior based on the data in the event.
|
||||
|
||||
> Note about forms: if an event handler is attached to the `onsubmit` event of a form, default behavior is to **not submit it**, meaning having `prevent_default: "onsubmit"` will submit it in this case.
|
||||
|
||||
## Handler Props
|
||||
|
||||
Sometimes, you might want to make a component that accepts an event handler. A simple example would be a `FancyButton` component, which accepts an `on_click` handler:
|
||||
|
||||
@@ -64,3 +64,5 @@ Então, você pode usá-lo como qualquer outro manipulador:
|
||||
> Nota: assim como qualquer outro atributo, você pode nomear os manipuladores como quiser! Embora eles devam começar com `on`, para que o prop seja automaticamente transformado em um `EventHandler` no local da chamada.
|
||||
>
|
||||
> Você também pode colocar dados personalizados no evento, em vez de, por exemplo, `MouseData`
|
||||
|
||||
> Nota sobre formulários: se um manipulador de evento está anexado ao evento `onsubmit` em um formulário, o comportamento padrão é de **não submetê-lo**. Portanto, especificar `prevent_default: "onsubmit"` irá submetê-lo.
|
||||
Reference in new issue
Block a user