Ivan
Ivan

Reputation: 510

October CMS | How to turn off flash messages or alerts

On my application I need to throw some erros, so following the documentation I can throw some errors with custom messages and/or render some partial by using the following code:

throw new AjaxException([
     '#error_box' => Lang::get('xxx.xxxx::lang.frontend.error_ajax_und')
]);

The problem is that I see flash messages with "Default text" and I don't know how to turn it off...

enter image description here

debug mode is disabled

october build: 419

Upvotes: 1

Views: 1260

Answers (1)

LukeTowers
LukeTowers

Reputation: 1291

In theory you could hook into the ajaxSetup event to disable flash error handling: http://octobercms.com/docs/ajax/javascript-api#global-events-examples

Something along the lines of:

$(document).on('ajaxSetup', function(event, context) {
    // Disable AJAX handling of Flash messages on all AJAX requests
    context.options.flash = false
})

or

$(document).on('ajaxSetup', function(event, context) {
    // Handle Error Messages with a custom handler
    context.options.handleErrorMessage = function(message) {
        // do stuff
    }

    // Handle Flash Messages with a custom handler
    context.options.handleFlashMessage = function(message, type) {
        // do stuff
    }
})

Upvotes: 2

Related Questions