vincent15000's avatar

How to send a response without any redirection ?

Hello,

form.post(
    route('player.quest.step.challenge.validate', { quest: props.quest_id, step: props.step_id, challenge: props.challenge }),
    {
        preserveScroll: true,
        onSuccess: (page) => {
            validated.value = page.flash.validated;
        },
    },
);
public function validate(PlayerChallengeValidationRequest $request, Quest $quest, Step $step, Challenge $challenge)
{
    $answer = $request->answer;

    $validated = $challenge->validate($answer);

    Inertia::flash('validated', $validated);

    return back();
}

I need to send the response to the frontend and preserve the scroll position.

The code above doesn't preserve the scroll position and I don't understand why.

Any idea ? I think that it's due to the return back() line.

Is there any way to perform an InertiaJS response with flash data with scroll position preservation ?

Thanks for your help.

V

0 likes
1 reply
vincent15000's avatar

I just noticed that the scroll is preserved, but bad preserved.

While revisiting the page after the POST request, the scroll moves a bit because I hide a div and add some other content.

So I have a new question : what is the reference of the scroll position to preserve it and is it possible to change / customize this reference ?

Please or to participate in this conversation.