Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wire:loading when redirecting a response

I have this

<div wire:loading>
   loading.....
</div>

component:

public function doMySubmit(){

  //something slow

  return redirect('/');
}

problem is, that loading stops once the redirect gets returned to the browser, the redirect means though that the browser just STARTS to redirect.

So on doMySubmit I show a splash screen, but once the redirect, it disappears and the form becomes editable again at least until the redirect response gets an answer and the browser starts to paint the new page.

any fix?

like image 421
Toskan Avatar asked May 21 '26 14:05

Toskan


1 Answers

The mechanics of Livewire does not work like this. It only shows a loading indicator until the request is resolved. What you can do, is make the loading logic yourself, by introducing a loading-variable like this:

public $loading = false;

public function doMySubmit() {

  $this->loading = true;

  return redirect('/');
}
@if($loading)
 <div>
    loading.....
 </div>
@endif
like image 174
Milkmannetje Avatar answered May 26 '26 01:05

Milkmannetje