I'm having issues showing my ajax spinner. Right now I am testing this on my localhost:3000/test
with the following code:
I click a link to get the loader to show (Ruby on Rails code):
<li><%= link_to "New Test", new_test_path, :remote => true %></li>
I have the div
the loader should appear inside:
<div id="generate-add-form">
<div class="ajax-loader"></div>
</div>
Then my functions to make it appear:
jQuery( function($) {
$('#generate-add-form').ajaxStart( function() {
$(this).children('.ajax-loader').show();
});
$('#generate-add-form').ajaxStop( function() {
$(this).children('.ajax-loader').hide();
});
});
Last is my css (some stuff commented out to see if its needed or not):
.ajax-loader {
display: none;
/*position: fixed;*/
z-index: 1000;
/*top: -13em;
left: 6em;*/
background:url('ajax-loader.gif') 50% 50% no-repeat;
}
body.loading {
overflow: hidden;
}
body.loading .ajax-loader {
display: block;
}
How come when I click the link it doesn't show?
EDIT:
<li><%= link_to "Test", new_test_path, :class => "add-link", :remote => true %></li>
<li><%= link_to "Study Guide", new_study_guide_path, :class => "add-link", :remote => true %></li>
$('#generate-add-form').children('.ajax-loader').hide();
$('.add-link').click( function() {
$('#generate-add-form').children('.ajax-loader').show();
});
I hide the spinner first and then show it again on click. What about in between when switching to another link?