So here is my attempt to explain some of the features. I'll create two sample blog apps, one using Prototype and the other using JQuery (the code is available on github).
Install Rails 3
If you haven't already, get Rails 3 installed. Everything you need to know is here.
What is UJS?
This preference for Prototype lead people to want a more loosely coupled approach, which didn't discriminate against other JS frameworks. Enter UJS...
How it works
Let's give it a go!
I'm not going to take you through the whole process of creating the Rails app. What I will show you is the parts that relate to UJS requests.
As I said this is a sample Blog app, so we have a Posts - Comments relationship set up. In the show.html.erb view we have a form for creating new comments:-
The main thing to notice about the form_for block is the :remote => true parameter. This will take care of the data-remote=true HTML5 attribute, that we discussed earlier. So when we submit this form it will send an ajax request to the "create" action in the comments controller:-
Notice that the controller responds to the :js format. So the controller will pass control to the create.js.erb view:-
This displays the new comment at the bottom of the list and highlights it, then finally it clears the form text area.
I've used the :remote => true option for deleting posts as well. Take a look at the demo code to see how this works. It's very similar to the example above.
That's pretty much it. Here's the prototype and jquery demos on github.