Skip to content
Snippets Groups Projects
Commit d7c95de6 authored by Xavier Perseguers's avatar Xavier Perseguers Committed by Frank Nägler
Browse files

[BUGFIX] Flash messages are not shown with AJAX requests

Direct DOM manipulation is avoided in favour of using the
top.Notification object to trigger TYPO3 7 native notifications.

Resolves: #71453
Related: #56561
Releases: master
Change-Id: I8c39d8100153b106e89ee1e7259ff1a0cc7ad572
Reviewed-on: https://review.typo3.org/44652


Reviewed-by: default avatarHelmut Hummel <helmut.hummel@typo3.org>
Tested-by: default avatarHelmut Hummel <helmut.hummel@typo3.org>
Reviewed-by: default avatarFrank Nägler <frank.naegler@typo3.org>
Tested-by: default avatarFrank Nägler <frank.naegler@typo3.org>
parent 9cdb8831
Branches
Tags
No related merge requests found
......@@ -1789,7 +1789,22 @@ function jumpToUrl(URL) {
*/
public function renderQueuedFlashMessages(ServerRequestInterface $request, ResponseInterface $response)
{
$response->getBody()->write($this->getFlashMessages());
/** @var $flashMessageService \TYPO3\CMS\Core\Messaging\FlashMessageService */
$flashMessageService = GeneralUtility::makeInstance(\TYPO3\CMS\Core\Messaging\FlashMessageService::class);
/** @var $defaultFlashMessageQueue \TYPO3\CMS\Core\Messaging\FlashMessageQueue */
$defaultFlashMessageQueue = $flashMessageService->getMessageQueueByIdentifier();
$flashMessages = $defaultFlashMessageQueue->getAllMessagesAndFlush();
$messages = [];
foreach ($flashMessages as $flashMessage) {
$messages[] = [
'title' => $flashMessage->getTitle(),
'message' => $flashMessage->getMessage(),
'severity' => $flashMessage->getSeverity()
];
}
$response->getBody()->write(json_encode($messages));
return $response;
}
......
......@@ -277,12 +277,9 @@ define(['jquery', 'moment', 'nprogress', 'TYPO3/CMS/Backend/Modal', 'TYPO3/CMS/L
url: TYPO3.settings.ajaxUrls['flashmessages_render'],
cache: false,
success: function(data) {
var messages = $('#typo3-messages');
if (messages.length == 0) {
$('#typo3-inner-docbody').prepend(data);
} else {
messages.replaceWith(data);
}
$.each(data, function(index, flashMessage) {
top.TYPO3.Notification.showMessage(flashMessage.title, flashMessage.message, flashMessage.severity);
});
}
});
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment