Skip to content

Commit 97188b8

Browse files
committed
clarify the javascript side for the flash listener
1 parent 14580e8 commit 97188b8

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

Resources/doc/features/helpers/flash-message.rst

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,25 @@ to only show the flash message once. Something along these lines:
5151
5252
var flashes = JSON.parse(decodeURIComponent(cookie));
5353
54-
// show flashes in your DOM...
54+
var html = '';
55+
for (var key in flashes) {
56+
if (key === 'length' || !flashes.hasOwnProperty(key)) {
57+
continue;
58+
}
59+
html = '<div class="alert alert-' + key + '">';
60+
html += '<i class="fa fa-info-circle"></i>';
61+
html += flashes[key];
62+
html += '</div>';
63+
}
64+
// YOUR WORK: show flashes in your DOM...
5565
66+
// remove the cookie to not show flashes again
5667
document.cookie = "flashes=; expires=Thu, 01 Jan 1970 00:00:01 GMT;";
5768
}
5869
59-
// register showFlash on the page ready event.
70+
// YOUR WORK: register showFlash on the page ready event.
71+
72+
The parts about adding the flash messages in the DOM and registering your handler depend on the Javascript framework you use in your page.
6073

6174
Your VCL configuration should `filter out this cookie <https://www.varnish-cache.org/trac/wiki/VCLExampleRemovingSomeCookies>`_
6275
on subsequent requests, in case the JavaScript failed to remove it.

0 commit comments

Comments
 (0)