Hi, I thought I understood how Flash messages are working, but looks like I didn't. I have:
$(document).on('ajaxSetup', function(event, context) {
// Enable AJAX handling of Flash messages on all AJAX requests
context.options.flash = true
// Enable the StripeLoadIndicator on all AJAX requests
context.options.loading = $.oc.stripeLoadIndicator
// Handle Error Messages by triggering a flashMsg of type error
context.options.handleErrorMessage = function(message) {
$.oc.flashMsg({ text: message, class: 'error' })
}
// Handle Flash Messages by triggering a flashMsg of the message type
context.options.handleFlashMessage = function(message, type) {
$.oc.flashMsg({ text: message, class: type })
}
})
at the end of my layout files, and it's working as expected when using AJAX, but now, when I try to redirect to Home page, with a Flash message, instead of displaying "No records" on the page, it doesn't work.
I have this, in a CMS page PHP section:
if(isset($node)){
$this['record'] = $node;
} else {
return Redirect::to('/')->with('message', 'Page not found!');
}
In the home page php section:
function onStart()
{
$message = Session::get('message');
if(isset($message)){
$message = Message::trans($message);
Flash::info($message);
Session::forget('message');
}
}
This doesn't display anything untill I don't put:
{% flash %}
<p
data-control="flash-message"
class="flash-message fade {{ type }}"
data-interval="5">
{{ message }}
</p>
{% endflash %}
in the markup section. Where I use AJAX, it works without...
But then, with the above code in the markup section, the message is displayed and if I rerfesh the page it's displayed again, once more. If I open /backend instead of refresh it's also displayed....
What am I missing here..?
Last updated