Skip to content

Commit abbf0fc

Browse files
committed
Add formnoajax example
1 parent acc3bff commit abbf0fc

1 file changed

Lines changed: 10 additions & 0 deletions

File tree

docs/reference.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,16 @@ Use the `x-target.push` modifier to push a new history entry onto the browser's
121121

122122
In cases where you have a form with multiple submit buttons, you may not always want all submit buttons to trigger an AJAX request. Add the `formnoajax` attribute to a submit element to instruct the form to make a standard full-page request instead of an AJAX request.
123123

124+
```html
125+
<form id="checkout" x-init x-target method="post" action="/checkout">
126+
<button name="procedure" value="increment">Increment quantity</button>
127+
<button name="procedure" value="decrement">Decrement quantity</button>
128+
<button formnoajax name="procedure" value="purchase">Complete checkout</button>
129+
</form>
130+
```
131+
132+
In this example clicking "Increment" or "Decrement" will issue an AJAX request. Clicking "Complete Checkout" will perform a standard form submission.
133+
124134
## x-merge
125135

126136
By default incoming HTML from the server will `replace` a targeted element. You can add `x-merge` to a targeted element to change how it merges incoming content. For example, if you wanted to `append` new items to a list of messages, you would add `x-merge="append"` to the list:

0 commit comments

Comments
 (0)