In this episode, we take a break from forms and dive into partial reloads with Inertia.js. We start by adding a simple "Refresh Comments" button under the comment form, which lets users manually reload the comments list without refreshing the whole page. This comes in handy if multiple users might leave comments, and you'd like to see the latest ones before submitting your own.
You'll see how to create the button using Vue (with a proper type="button"
, styling, and an event handler method), then write the reloadComments
method. Here, you'll learn how to make a manual GET
request using Inertia's router to update only the comments.
But that's not all. We hit a practical issue: every time we use Inertia's router to reload the page's data, all props are re-fetched by default—even stuff we don't need, like authentication info or timestamps. To solve this, we use Inertia's "partial reloads" and the only
option, making sure only the posts
(our comments) prop updates. This is more efficient, especially as your app grows.
We also quickly demo how to "preserveScroll" so your scroll position doesn't jump around when you reload. By the end, you'll have a nice pattern for updating only what you need on the page, keeping things fast and snappy as your app gets more complex!
Key takeaways:
It's a super practical episode that will make your Inertia-powered apps feel way more dynamic and efficient.