Rails 1.1 and RJS Templates for Easily Ajaxifying your Webapp

Rails 1.1 has arrived!

RJS is a templating language that allows you to write JavaScript in a native Ruby style.

Some Good RJS Links

Cody Fauser's Intro to Rails' RJS
More on RJS and some of its advanced features
Rails JavaScript Generator Methods

Now, here's an absolute Must-Have RJS Debugging Snippet to drop into your rhtml page when you're playing around with this stuff:

RUBY:
  1. <div id="debug">
  2. </div>
  3. <script type="text/javascript">
  4.     Ajax.Responders.register({
  5.     // log the beginning of the requests
  6.     onCreate: function(request, transport) {
  7.     new Insertion.Bottom('debug', '<p><strong>[' + new Date().toString() + '] accessing ' + request.url + '</strong></p>')
  8.     },
  9.    
  10.     // log the completion of the requests
  11.     onComplete: function(request, transport) {
  12.     new Insertion.Bottom('debug',
  13.     '<p><strong>http status: ' + transport.status + '</strong></p>' +
  14.     '<pre>' + transport.responseText.escapeHTML() + '</pre>')
  15.     }
  16.     });
  17. </script>

(via techno-weenie)

You can Bookmark this entry on del.icio.usbookmark this, digg this entrydigg this or check the See this page in technoraticosmos


Shanti A. Braford blogs here.

If you really want to know, just read this.



  

Powered by FeedBlitz