0

I am trying to get ajax callbacks working on a href using remote. I have the rails.js and JQuery1.6 installed.

Here is the attempt to catch the callback:

$('#choo').bind('ajax:success', function(){
    alert("Success!");

});

Here is my div and AJAX link

<%= link_to "Choose", {:action => "choose", :id => 538}, :remote => true, :id => "choo" %>

When I click the link the ajax fires hits the server and returns the response but the callback is not working...

I have followed everything in this guide but with little by the way of success. In other words "!ajax:success" :-).

Any ideas what I am doing wrong?

EDIT++++++++++++++++++++==

I updated to 3.1 and it worked.

Cheers,

s

2
  • 1
    Did you try binding to the ajax:beforeSend? Not sure how Rails' UJS works, so less sure if ajaxStart would work the same way as with raw jQuery. Commented Sep 21, 2011 at 12:47
  • @Dave Newton. I did what you suggested bu still no dice. Thanks for the comment though. Commented Sep 23, 2011 at 8:07

1 Answer 1

1

Try to "live"

$('#choo').live('ajax:success', function(){
  alert("Success!");
});

or this:

$('a[data-remote],input[data-remote]').live('ajax:success', function() {
  alert('success');
});
Sign up to request clarification or add additional context in comments.

2 Comments

I've tried both of these but let me try them again and I'll get back to you.
Nope, neither of these work, which makes me thing there may be some thing wrong with rails.js....

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.