inertia-laravel icon indicating copy to clipboard operation
inertia-laravel copied to clipboard

Partial reload -> Lazy data evaluation with dynamic page content

Open GarethSomers opened this issue 3 years ago • 2 comments

Hello,

I'm considoring a project to use Inertia JS but I could not determine how to partially reload a dynamic layout.

In my scenario I would be using a page builder to store a multi dimension array (represented in json) in a field (e.g. "content"), for example (with the data "injected")

return Inertia::render('Pages/Home', [
    'content' => Inertia::lazy(fn () => [
        {
            layout: 'collection_that_ajaxs",
            page: 0,
            records: [...]
        },
        {
            layout: 'etc'
        },
    ])
]);

Say "collection_that_ajaxs" needs to do a partial reload (where page = 1), but I don't also wish to reload everything from the "content" field. Is this possible?

GarethSomers avatar Apr 29 '22 06:04 GarethSomers

A bit late, but I guess you can do this with an initial get route and a post. But you need to configure HandleInertiaRequests, like this image

Something like this public function function_name(Request $request) { $request->validate([...]); //Check if data is correct $query = "do your stuff here..." return back()->with(['sucess' => $query]); ]); } Then you access the data that should be flashed in the props props.flash.success

99Arrzel avatar Jun 08 '22 10:06 99Arrzel

Your best bet for now is to store a copy of the props and update them/merge them manually when the original changes

Otherwise https://github.com/inertiajs/inertia/pull/1247 would solve this

Tofandel avatar Aug 19 '22 12:08 Tofandel

Hey there,

We're closing this issue because it's inactive, already solved, old or not relevant anymore. Feel free to open up a new issue if you're still experiencing this problem.

jessarcher avatar Sep 08 '23 01:09 jessarcher