Skip to content

Commit

Permalink
docs: new visit options from inertiajs/inertiajs.com#364
Browse files Browse the repository at this point in the history
  • Loading branch information
skryukov committed Oct 14, 2024
1 parent 0cac4dd commit dfef20d
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 1 deletion.
30 changes: 30 additions & 0 deletions docs/guide/manual-visits.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,17 @@ router.visit(url, {
preserveState: false,
preserveScroll: false,
only: [],
except: [],
headers: {},
errorBag: null,
forceFormData: false,
queryStringArrayFormat: 'brackets',
async: false,
showProgress: true,
fresh: false,
reset: [],
preserveUrl: false,
prefetch: false,
onCancelToken: (cancelToken) => {},
onCancel: () => {},
onBefore: (visit) => {},
Expand All @@ -26,6 +34,8 @@ router.visit(url, {
onSuccess: (page) => {},
onError: (errors) => {},
onFinish: (visit) => {},
onPrefetching: () => {},
onPrefetched: () => {},
})
```

Expand All @@ -41,9 +51,17 @@ router.visit(url, {
preserveState: false,
preserveScroll: false,
only: [],
except: [],
headers: {},
errorBag: null,
forceFormData: false,
queryStringArrayFormat: 'brackets',
async: false,
showProgress: true,
fresh: false,
reset: [],
preserveUrl: false,
prefetch: false,
onCancelToken: (cancelToken) => {},
onCancel: () => {},
onBefore: (visit) => {},
Expand All @@ -52,6 +70,8 @@ router.visit(url, {
onSuccess: (page) => {},
onError: (errors) => {},
onFinish: (visit) => {},
onPrefetching: () => {},
onPrefetched: () => {},
})
```

Expand All @@ -67,9 +87,17 @@ router.visit(url, {
preserveState: false,
preserveScroll: false,
only: [],
except: [],
headers: {},
errorBag: null,
forceFormData: false,
queryStringArrayFormat: 'brackets',
async: false,
showProgress: true,
fresh: false,
reset: [],
preserveUrl: false,
prefetch: false,
onCancelToken: (cancelToken) => {},
onCancel: () => {},
onBefore: (visit) => {},
Expand All @@ -78,6 +106,8 @@ router.visit(url, {
onSuccess: (page) => {},
onError: (errors) => {},
onFinish: (visit) => {},
onPrefetching: () => {},
onPrefetched: () => {},
})
```

Expand Down
25 changes: 24 additions & 1 deletion docs/guide/progress-indicators.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Progress indicators

Since Inertia requests are made via XHR, there would typically not be a browser loading indicator when navigating from one page to another. To solve this, Inertia displays a progress indicator at the top of the page whenever you make an Inertia visit.
Since Inertia requests are made via XHR, there would typically not be a browser loading indicator when navigating from one page to another. To solve this, Inertia displays a progress indicator at the top of the page whenever you make an Inertia visit. However, [asynchronous requests](#visit-options) do not show the progress indicator unless explicitly configured.

Of course, if you prefer, you can disable Inertia's default loading indicator and provide your own custom implementation. We'll discuss both approaches below.

Expand Down Expand Up @@ -294,3 +294,26 @@ router.on('finish', (event) => {
```
:::
## Visit Options
In addition to these configurations, Inertia.js provides two visit options to control the loading indicator on a per-request basis: `showProgress` and `async`. These options offer greater control over how Inertia.js handles asynchronous requests and manages progress indicators.
### `showProgress`
The `showProgress` option provides fine-grained control over the visibility of the loading indicator during requests.
```js
router.get('/settings', {}, { showProgress: false })
```
### `async`
The `async` option allows you to perform asynchronous requests without displaying the default progress indicator. It can be used in combination with the `showProgress` option.
```js
// Disable the progress indicator
router.get('/settings', {}, { async: true })
// Enable the progress indicator with async requests
router.get('/settings', {}, { async: true, showProgress: true })
```

0 comments on commit dfef20d

Please sign in to comment.