The default Inertia-js behavior does not have that kind of feature. I suggest you to use this package for Modal. https://github.com/lepikhinb/momentum-modal
Inertia loading up a page within a page
I'm sure I'm missing something obvious in the Inertia docs here, but I'm really not sure how best to do this.
I have a simple forum that is accessed via a GET request to /feed
In my FeedController:
public function index(): Response
{
return Inertia::render('Feed/Feed', [
'posts' => fn() => Post::orderBy('updated_at', 'desc')
->get(),
]);
}
Straightforward. Now I want to add the functionality that the user can click on a Post which opens a lightbox and displays the Post fully and all of it's relationships etc which means making a request to the server.
My challenge is how to do this with Inertia without affecting the feed that sits behind the lightbox.
I can add a featured prop returned by the index() method which is initially null and then run a partial reload each time the user clicks a post
public function index(Request $request): Response
{
return Inertia::render('Feed/Feed', [
'posts' => fn() => Post::orderBy('updated_at', 'desc')
->get(),
'featured' => fn() => $request->featured ? Post::find($request->featured) : null,
]);
}
But this feels like a bodge to me: I now have a single method that needs to accept both GET and POST (assuming I want to hide the url). And to try and stick with SOLID principles I would prefer to have a show() method return the individual Post with relationships.
Any ideas on how to do this 'right'?
Please or to participate in this conversation.