mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-20 12:23:02 +00:00
docs(form): add "Prevent default behavior" example
This commit is contained in:
parent
77a77977ab
commit
f7c85096da
1 changed files with 14 additions and 0 deletions
|
@ -60,3 +60,17 @@ components: ["Form", "FormGroup"]
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
<Button type="submit">Submit</Button>
|
<Button type="submit">Submit</Button>
|
||||||
</Form>
|
</Form>
|
||||||
|
|
||||||
|
### Prevent default behavior
|
||||||
|
|
||||||
|
The forwarded `submit` event is not modified. Use `e.preventDefault()` to prevent the native form submission behavior.
|
||||||
|
|
||||||
|
```
|
||||||
|
<Form on:submit={e => {
|
||||||
|
e.preventDefault();
|
||||||
|
console.log("submit", e);
|
||||||
|
}}>
|
||||||
|
<Checkbox id="checkbox-0" labelText="Checkbox Label" checked />
|
||||||
|
<Button type="submit">Submit</Button>
|
||||||
|
</Form>
|
||||||
|
```
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue