Hello,
I am struggling doing something simple using Inertia.
I have a page presenting an online Course with a sticky sidebar showing Course details and tabs with specific course data like : main content, chapters, faq, reviews...
The data are simply rendered using Inertia::render('courses/CourseDetail', ...) and it works.
Now I would like to optimize the speed and UX, so naturally lazy load each tab on click.
- First I tried to load json data, but I loose the inertia behaviour for rendering the component and I have to manage all by myself that is not very smart.
- Then I used router.get(url, {}, { preserveScroll: true, preserveState: true}); which calls the same method in the controller and use again Inertia::render.
On one hand, returning only the tab data (ex for the reviews), my stickybar with the course data makes an error because course data is missing. On the other hand, returning the Course data for each tab request is not very optimized as it will request my Eloquent model (that is already displayed) for each tab.
I tried many solutions (also using pinia) but I'm not able to make something clean and optimized. The hard part is also that I have this sticky bar that must be visible whatever the tab is visited.
Also I would like to remember the tab data somewhere in order to not request the backend if tab was previously loaded. Also the reviews tab must be able to handle the pagination.
It looks very easy but I struggle using Inertia and vue to make it work.
Can someone help me to make something clean please ?
Thank you
Stack : Laravel 12, Vue, Inertia.