Hello,
I'm trying to compare two ways to load a model datas in a modal form.
I have a table with (for example) books and for each category I have a button to edit it. Furthermore I have a modal form. This is my Books/Index.vue page.
When I click on the button, I have two options to code how the modal form will be filled :
- eiter I refresh the
Books/Index.vue page, I load only the books (Inertia::render(..., only: 'book', ...)) and I access to the book datas with usePage()
- or I pass the
bookId to the modal form and the modal form send a simple axios request to retrieve the book datas
I know that I have already asked similar questions in previous posts (similar but not exactly the same) and this is a real problem for me because modal forms is not how InertiaJS works.
IMHO I think that it's cleaner to use a simple axios request for the modal form and keep the InertiaJS request to refresh the table.
One more question : if I visit the same page again with an InertiaJS request by specifying for example only books, I have understood that the controller will only reload the books list and not the other datas which will be retrieved from the state. But in the frontend part of the code, does the entire page refresh (with the menu and other data from the state) ? Or only the books table ?
I have perhaps an idea of the answer : the entire page will be reloaded, retrieving the datas from the controller (if reloaded) or from the state (if not reloaded). If this is right, the best way to load datas in my modal form is perhaps the axios way.
What do you think about all this ?
Thanks for your help.
V