Flash message not showing when redirecting to same page?
See original GitHub issueVersions:
@inertiajs/inertia
version: 0.8.7@inertiajs/inertia-vue
version: 0.5.12
Describe the problem:
Flash messages are not being displayed when you redirect back to the same page? We have a page that contains a regular vue component. The component contains a form that performs a post submission. The receiving controller performs a redirect back to the same page. The flash message is not being displayed. When you redirect to another page, then the flash message is being displayed.
The initialPage.props.flash.message remains ‘null’.
What does catch my eye is that the xhr response does contain the flash message though…
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (1 by maintainers)
Top Results From Across the Web
Flask Flash message not showing after redirecting to the same ...
So when I try your new code and test it with an erroneous file upload, it does the same thing still - it...
Read more >How to Flash messages in same page without redirecting?
I see this in the Store class, and I'm trying to use if but it's not working. Copy Code session()->now('success', 'The client was...
Read more >Flash messages from Laravel not shown in Inertia after ...
It seems to work fine until I do a Redirect::route('auth.index')->with([...]) Then the success or error message won't fire at all. Works fine if ......
Read more >Rails: on redirect to same page form submitted from, flash ...
Typically the flash is rendered in the application's layout file. This avoids the duplication of having to output <%= flash[:notice] %> in every...
Read more >HTTP Redirects - The PHP Framework For Web Artisans
When you call the redirect helper with no parameters, an instance of ... to a new URL and flashing data to the session...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@seewhy17 , thanks for your feedback. You actually made me realise how to improve this. I was only looking for the flash messages in the created lifecycle callback (vue2 due to vuetify dependency). I have now made it a watcher that looks like this:
MessageStore is a messagebus that takes care of displaying the messages.
Works like a charm.
Can me closed afaik. ❤️
@mathiasselleslach I think you could display the flash message in several ways You could get the message from any component by importing
Inertia
orusePage
like soand get the message using
Inertia.page.props.flash.message
orusePage().props.value.flash.token
Alternatively, you can create a local prop
flash
on your component.