Skip to content

clarify the javascript side for the flash listener #248

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 16, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions Resources/doc/features/helpers/flash-message.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,24 @@ to only show the flash message once. Something along these lines:

var flashes = JSON.parse(decodeURIComponent(cookie));

// show flashes in your DOM...
var html = '';
for (var key in flashes) {
if (key === 'length' || !flashes.hasOwnProperty(key)) {
continue;
}
html = '<div class="alert alert-' + key + '">';
html += flashes[key];
html += '</div>';
}
// YOUR WORK: show flashes in your DOM...

// remove the cookie to not show flashes again
document.cookie = "flashes=; expires=Thu, 01 Jan 1970 00:00:01 GMT;";
}

// register showFlash on the page ready event.
// YOUR WORK: register showFlash on the page ready event.

The parts about adding the flash messages in the DOM and registering your handler depend on the Javascript framework you use in your page.

Your VCL configuration should `filter out this cookie <https://www.varnish-cache.org/trac/wiki/VCLExampleRemovingSomeCookies>`_
on subsequent requests, in case the JavaScript failed to remove it.
1 change: 1 addition & 0 deletions Resources/doc/spelling_word_list.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ yaml
invalidator
ETag
templating
Javascript
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be JavaScript (capital s).

Copy link
Contributor Author

@dbu dbu Nov 16, 2015 via email

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.