More about Flash messages.
-
Can you tell me how to use them properly? How they are invoked?
And mostly how to invoke them after an Ajax request because currently i find that messages work only when pages are reloaded.
Thank you. -
We have created a method called 'addFlashMessages' in our js file, using which you can invoke them during time of ajax request.
window.flashMessages = [{ 'type': 'alert-success', 'message': response.data.message } this_this.$root.addFlashMessages();
Note -
'type' => 'alert-success', 'alert-warning, 'alert-error' & 'alert-info'.
'message' => response message returning from controller.Thanks
-
can you explain a bit more with some examples. Thank you
-
A flash message is used to communicate back to the user of the website or application that an event has taken place.This may be something the user intended to do, or it might be something that is just informational. The key to remember about flash messages is that they are not persistent.They can be success message, error message, info message, warning message etc.
Just think that we have completed an action & did not show any information about that to user then what a user will think.Whether its done or not. He will not clear with action.
So, after every event we show flash message to user accordingly -Success - session()->flash('success', trans('admin::app.response.update-success', ['name' => 'Attribute'])); Error - session()->flash('error', trans('admin::app.response.delete-failed', ['name' => 'Attribute'])); Warning - session()->flash('warning', trans('admin::app.response.customer-associate', ['name' => 'Customer Group'])); Info - session()->flash('info', trans('admin::app.datagrid.mass-ops.partial-action', ['resource' => 'attributes']));
Thanks
-
Interesting