I am new to using Jquery in Rails. Could anyone provide a working example of a message that content is loading. I do not want to use the global ajaxStart because I don't want it called everytime.
I have partials that are pretty content heavy and would like to have a message just pop up telling people it is loading.
I have looked around and see bits and pieces of code to accomplish this, but I don't seem to grasp where all this goes.
Anything to point me in the right direction would be great.
My code: index.html
<%= link_to 'Health & Beauty', health_contacts_path, :action => 'health', :remote => true %>
health.js
$(function (){
$(".health")
.bind("ajax:beforeSend", function() {
$("#spinner").show('slow');
});
.bind("ajax:success", function() {
$("#spinner").hide();
});
.bind("ajax:complete", function(event, data, status, xhr) {
$("#content").html("<%= escape_javascript(render(:partial => "health")) %>");
});
});
Thanks so much
EDIT: I changed the code in health.js, I don't understand what this is not working. If I take out the ajax:beforeSend and ajax:success then ajax:complete will load. If those two are in there nothing works.