I have a link that when i click on it will trigger an ajax call then replace this link by another link, says for example the original link is \"add friend\", when i click th
I met this problem before, UJS's ajax:success and ajax:complete won't be fired. But other callbacks work, such as ajax:beforeSend
My fix is to use jQuery's global event callback to handle it
$("#my_link").on('ajaxComplete', (evt, data, status, xhr) ->
alert('This is a jQuery ajax complete event!')
P.S. UJS use jQuery's ajax to send Ajax, so jQuery's callback will surely be fired.
# https://github.com/rails/jquery-ujs/blob/master/src/rails.js
ajax: function(options) {
return $.ajax(options);
},