Open kylekanderson opened 1 year ago
Note: the $this->flash()
method works as expected in the mount()
method. However, it seems the $this->alert()
and $this->confirm()
methods do not.
I have found that removing this return;
statement enabled the $this->alert()
and $this->confirm()
methods to work: https://github.com/jantinnerezo/livewire-alert/blob/cf7c57b2e8541a33f62215d58c540d81e33fd26d/src/LivewireAlert.php#L90
Of course, I'm not sure what the repercussions are elsewhere of removing that line.
I believe this could be easily changed.. .the return seems to just stop it from doing the Flash portion...
this could easily be adjusting to a compact if
$isFlash ? session('flash stuff...') : $this->dispatchBrowserEvent('...stuff...');
completely removing the return;
Unfortunately, the session took precedence, if the return is removed... so the reason you saw the alert, was because it was running as session flash, and not a dispatched alert... wrapping the session in an else, prevents the alert from showing... so it really worked as a session flash message in Mount and not an actual dispatched alert... :'( wish this worked
I'm assuming this doesn't work for alert, because the page hasn't really been viewed yet, thus there is no javascript to listen and run the alert... the only thing I can think of, is to somehow use it as a session flash value without actually redirecting...
Note: the
$this->flash()
method works as expected in themount()
method. However, it seems the$this->alert()
and$this->confirm()
methods do not.I have found that removing this
return;
statement enabled the$this->alert()
and$this->confirm()
methods to work:Of course, I'm not sure what the repercussions are elsewhere of removing that line.
I believe we can use wire:init to perform an action once the page has been viewed, and then update information... going to test this theory out and see what happens :D
I have some use cases where I'd like to use
$this->alert()
in themount()
method of my component. This doesn't appear to be supported currently - are there any plans to support this in the future?