Skip to content

Instantly share code, notes, and snippets.

@levelone
Last active June 26, 2018 23:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save levelone/7941d53bb1793d1c8251df5dd4ed742a to your computer and use it in GitHub Desktop.
Save levelone/7941d53bb1793d1c8251df5dd4ed742a to your computer and use it in GitHub Desktop.
$.ajax({
// ...
}).fail(function(response){
window.Flash(response.message, 'error', $('.some-class-container'))
})
// ..helpers/flash_helpers.js
window.Flash = function (message, type, $container) {
$container = ($container == null) ? $('.container-fluid.container-page') : $container
var html =
'<div class="alert alert-flash alert-' + type + '">' +
'<button class="close" data-dismiss="alert" type="button">×</button>' +
'<div id="flash_alert">' +
'<i class="icon-thumbs-down"></i>' +
message +
'</div>' +
'</div>'
return $container.prepend(html);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment