4

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?

1

1 Answer 1

7

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.