I also don't know of any good guides for this.  You can see the
relevant RailsCast for it: 
http://railscasts.com/episodes/205-unobtrusive-javascript
where Ryan Bates discusses using the *.js.erb style of returning JS to
the page to be executed.

I'd recommend reading through the rails adapter you're using.  It will
help to give you some idea of how it works.  If using JQuery, you can
hook into a series of triggered events throughout the AJAX call
lifecycle. Here's an example to handle the response from a AJAX-y
link:

$('a[data-remote]').live('ajax:complete', function(xhr, response) {
      if (response.status == 200) {
        $('#resource-display').html(response.responseText);
      } else {
        $('#resource-display').html('Error loading content');
      }
    });

Fundamentally, though, there *does* need to be better documentation
about this.  It's certainly one of those 'someone needs to do it'
moments, and we can't really blame anyone else but ourselves!

Casey

On May 24, 7:25 am, Robert Walker <li...@ruby-forum.com> wrote:
> bill gate wrote in post #1000518:
>
> > forget ujs ,only use jquery
> > that is very easy and also work fine.
>
> @Tomas, ignore this reply Unobtrusive JavaScript (UJS) and jQuery are
> completely unrelated. One has nothing to do with the other. jQuery can
> be just as obtrusive, or unobtrusive, as any JavaScript.
>
> I do agree, however, it would be nice to have an "official" guide to
> JavaScript (& CoffeeScript).
>
> --
> Posted viahttp://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to