Skip to content

Instantly share code, notes, and snippets.

@fgrehm
Created February 19, 2013 15:48
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 fgrehm/4987039 to your computer and use it in GitHub Desktop.
Save fgrehm/4987039 to your computer and use it in GitHub Desktop.
Global ajax handlers
jQuery ($) ->
$indicator = $('#ajax-indicator')
$message = $indicator.find('span')
$(document).ajaxSend (event, jqXHR, ajaxOptions) ->
msg = if ajaxOptions.type == 'GET' then 'Carregando' else 'Processando'
$message.text("#{msg}...")
$indicator.show()
$(document).ajaxStop -> $indicator.hide()
$(document).ajaxError ->
alert('Ocorreu um erro ao processar sua requisição, por favor recarregue a página e tente novamente')
p#ajax-indicator
= image_tag 'busy.gif'
span
#ajax-indicator {
img { margin-right: $baseLineHeight / 2 }
display: none;
z-index: 1041;
position: fixed;
top: 0;
left: 50%;
margin-left: -80px;
width: 160px;
height: 25px;
background: $greenLight;
color: black;
text-align: center;
@include border-radius(0 0 5px 5px);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment