UJS guides somewhere?

I’m trying to work with AJAX on Rails 3 but I cant find any
documentation or a guide for learning it, is there a good one out there
to start practicing?

forget ujs ,only use jquery
that is very easy and also work fine.

On Tue, May 24, 2011 at 8:58 AM, Tomas R. [email protected] wrote:

I’m trying to work with AJAX on Rails 3 but I cant find any
documentation or a guide for learning it, is there a good one out there
to start practicing?

just add a .js.haml (or erb) template and add the js response to that
file.
for example,
you’re sending an ajax request to the create action of posts controller.
just
add a create.js.haml file and add the script you want in that file.

http://groups.google.com/group/rubyonrails-talk?hl=en.

On Tue, May 24, 2011 at 2:58 AM, Tomas R. [email protected] wrote:

I’m trying to work with AJAX on Rails 3 but I cant find any

documentation or a guide for learning it, is there a good one out there
to start practicing?

There has been a couple of attempts at writing an Ajax guide, but none
finished (and none ongoing as of this writing that I am aware of).

An Ajax guide would be very helpful if anyone wants to volunteer one :).

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).

so before trying ajax i need to learn javascript right?

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 B. 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

Yes, absolutely. AJAX stands for “Asynchronous Javascript”. So
learning some Javascript is key.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs