Thursday, November 16th, 2006

UJS Illustrated with Event Wax

Category: Library, Rails, Ruby, Unobtrusive JS

Dan Webb, one half of the team behind the Unobtrusive Javascript Plugin for Rails, posted an article on how he used UJS to develop a slick help sidebar for Event Wax.

He first gets the help sidebar working using a traditional request for the whole page, and then he adds the ajax functionality via apply_behavior calls from UJS. This ensures that for users without javascript they will still be able to use help, not to mention the links remain Google-friendly since they point to real resources and not just a JS event. Rails makes the server side piece easy with the respond_to method that looks at what the client is requesting and sends back either the full html page or just a javascript fragment for the ajax users.

All in all it looks just as easy as doing things the nasty way with inline events, so if you are using Rails there isn’t a good reason to not use UJS.

event wax screenshot

Posted by Rob Sanheim at 10:30 am
Comment here

3.8 rating from 28 votes

Comments Here »

Comments feed TrackBack URI

Leave a comment

You must be logged in to post a comment.