十月 CMS |如何关闭即显消息或警报
October CMS | How to turn off flash messages or alerts
在我的应用程序中,我需要抛出一些错误,所以在 documentation 之后,我可以用自定义消息抛出一些错误 and/or 使用以下代码呈现部分错误:
throw new AjaxException([
'#error_box' => Lang::get('xxx.xxxx::lang.frontend.error_ajax_und')
]);
问题是我看到带有 "Default text" 的闪现消息,但我不知道如何将其关闭...
调试模式已禁用
10 月版本:419
理论上,您可以挂接到 ajaxSetup
事件以禁用闪存错误处理:http://octobercms.com/docs/ajax/javascript-api#global-events-examples
大致如下:
$(document).on('ajaxSetup', function(event, context) {
// Disable AJAX handling of Flash messages on all AJAX requests
context.options.flash = false
})
或
$(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
}
})
在我的应用程序中,我需要抛出一些错误,所以在 documentation 之后,我可以用自定义消息抛出一些错误 and/or 使用以下代码呈现部分错误:
throw new AjaxException([
'#error_box' => Lang::get('xxx.xxxx::lang.frontend.error_ajax_und')
]);
问题是我看到带有 "Default text" 的闪现消息,但我不知道如何将其关闭...
调试模式已禁用
10 月版本:419
理论上,您可以挂接到 ajaxSetup
事件以禁用闪存错误处理:http://octobercms.com/docs/ajax/javascript-api#global-events-examples
大致如下:
$(document).on('ajaxSetup', function(event, context) {
// Disable AJAX handling of Flash messages on all AJAX requests
context.options.flash = false
})
或
$(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
}
})