Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

jesse_orange_newable's avatar

Updating elements in Interia

In my app I have a table of items and a button that says submit, when I press submit I thought Inertia would refresh the state in the background.

Here is the Vue file:

Also note that I'm using Ziggy.

Then in my Controller:

It is my understanding that the submit function should return the Index component but with updated data. Am I being silly or is there an Inertia thing I'm not seeing?

0 likes
1 reply
LaryAI's avatar
Level 58

To ensure that your Inertia.js application updates the state correctly after submitting a nomination, you need to make sure that the data is being re-fetched and updated in the Vue component. Here are a few steps to ensure this works correctly:

  1. Ensure the Controller Returns Updated Data: After submitting a nomination, the controller should return the updated list of nominations. This is already being done in your submit method by redirecting to the index route.

  2. Update the Vue Component: Ensure that the Vue component correctly handles the updated data. You are using Inertia.reload() in the onSuccess callback of the Inertia.post method, which should re-fetch the data.

  3. Check the Inertia Response: Make sure that the response from the server includes the updated data. Inertia should automatically update the component's props with the new data.

Here is a refined version of your Vue component and controller to ensure everything works as expected:

Vue Component

Controller

Ensure that the submit method in your controller returns the updated data correctly:

public function submit(Nomination $nomination)
{
    Gate::authorize('submit', $nomination);

    $nomination->update([
        'submitted_at' => Carbon::now()
    ]);

    return redirect()->route('values-awards.nominations.index');
}

Summary

  • The submit method in the controller updates the nomination and redirects to the index route.
  • The Vue component uses Inertia.reload() to re-fetch the data after the nomination is submitted.
  • Ensure that the index method in the controller returns the updated list of nominations.

By following these steps, your Inertia.js application should correctly update the state and display the updated list of nominations after a nomination is submitted.

Please or to participate in this conversation.