Working
<Link :href="route('products')" preserve-scroll>Products</Link>
Not Working
<form @submit.prevent="submit">
...
<button type="submit" preserve-scroll>Submit</button>
</form>
package.json
...
"dependencies": {
"@inertiajs/inertia": "^0.10.1",
"@inertiajs/inertia-vue3": "^0.5.2",
"@inertiajs/progress": "^0.2.6",
"vue": "^3.2.20"
}
...
I haven't found a way in the inertia documentation to preserve scrolling when clicking on buttons, did someone face it yet?
You need to tell the request you're making at the submit method to preserverScroll. Something like this:
submit () {
this.$inertia.post(url, data, {
preserveScroll: true
})
}
And you can remove the preserve-scroll from the button. That is useless.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With