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 believe your problem is down to JS not being able to bind to your object, as it's been changed. The way JS works is to "bind" / "attach" itself to elements in the DOM (Document Object Model). The DOM is basically a huge list of elements JS uses to call certain functions, and thus allows you to allocate various functions to those elements. That's how you can call "click" functions on different elements.
You're basically replacing the object that you've called the Ajax from, so when 'ajax:success' happens, JS has no way to know which object to associate it with, thus preventing the function from firing
The way to get around this is to bind to the document, and then delegate the bind to your div, like this:
$(document).on 'ajax:success' , '#my_link', ->
//do stuff here
This means that even if this element changes dynamically, it will still have the function bound to it, thus giving you what you need :)