I would like to place a \"please wait, loading\" spinning circle animation on my site. How should I accomplish this using jQuery?
If you are using Turbolinks With Rails this is my solution:
This is the CoffeeScript
$(window).on 'page:fetch', ->
$('body').append("")
$('body').addClass("loading")
$(window).on 'page:change', ->
$('body').removeClass("loading")
This is the SASS CSS based on the first excellent answer from Jonathan Sampson
# loader.css.scss
.modal {
display: none;
position: fixed;
z-index: 1000;
top: 0;
left: 0;
height: 100%;
width: 100%;
background: rgba( 255, 255, 255, 0.4)
asset-url('ajax-loader.gif', image)
50% 50%
no-repeat;
}
body.loading {
overflow: hidden;
}
body.loading .modal {
display: block;
}