Topic: ajax before:send, success, complete requests not working
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")) %>");
});
});
Last edited by looloobs (2011-07-24 10:01:15)