"des...">

JQuery Ajax not starting for rails remote link_to

I have the following remote link_to tag, defined as follows:

 =link_to "",  {:action => "destroy", :id => user.id}, :remote => true, :method => :delete, :class => "delete-icon"

This works fine, but I want to hook into jQuery 1.5.1 ajax events to provide a notification to the user. I have event handlers defined below, ajax: before the event fires, but none of the others do. Can anyone see what I'm doing wrong. I am testing this on safari 5

$(function(){ 
    $('.delete-icon').bind("ajax:before",  //fires
                function(){
               $('#progress').show(300);
    });

    $('.delete-icon').bind('ajax:after', //does not fire
        function(xhr, status, error) {
            alert("complete!");
    });

});
+3
source share
2 answers

You should try to bind to "complete" instead of "ajax: after". If you prefer to only notice when it succeeds, try "success" instead.

+2
source

"complete", 4

$('.delete-icon').bind('ajax:complete', //this will work
    function(event, data, status, xhr) { //note parametes
        alert("complete!");
});

Jquery-ujs JQuery Trigger

0

All Articles