Monday, May 9th, 2005

Ajax Summit: Sam Stephenson, Prototype

Category: Ajax, Prototype

The Rails flow continues. Sam Stephenson wrote Prototype, which is the JavaScript library that Rails uses to get its Ajax work done. (Although, it isn’t just for Rails, DHH says that there is even a CPAN module to spit out the same Prototype code).

It is a very pragmatic approach, that doesn’t try to add many layers of abstractions. It is a OO class design, that makes use of the “prototype” support that JavaScript offers for OO:

var timer = Class.create();

timer.prototype = {
  initialize: function(freq, callback) {
  tick: function() {

Inheritence and mixin support via: Object.prototype.extend

Ease the pain of DOM manipulation:

$('message').innertHTML = ''
new Insertion.Before('message', 'Message sent');

Compute form query strings via: Form.serialize

Ajax core helpers:

new Ajax.Request('/person/create', {
  parameters: Form.serialize('person'),
  onComplete: function() { ... }

What’s next

  • Documentation
  • Full test suites
  • Dojotoolkit collaboration
  • Components (live search)
  • Effects

Posted by Dion Almaer at 5:27 pm

3.4 rating from 7 votes


Comments feed

I see this library use the innerHTML method for DOM manipulation. But this would break the application if documents were served as XHTML 1.1. Does this means that actually Rails applications cannot use the more recent doctype? Is this a known issue to them?

Comment by Andrea Martines — May 10, 2005

I doubt they care, honestly. I know I don’t.

I just want to make my data-driven apps look nice, behave pleasantly, and do what the user wants.

I can’t think of what XHTML would give me at this point except perhaps some future neat stuff like inlined SVG (very, very future, I would guess).

Comment by Steve Willer — May 10, 2005

Web standards developers, they care. I’m really interested to Rails applications, but I won’t even touch that framework until I’ll be sure that their time saving procedures won’t lead to a higher time wasting work to rebuild all javascript routines for my web standards compliant products.
This is the thinking of too many people to simpy ignore the issue, comparing to the minimum effort they should face to address their code to compliance.
I’ll drop a note to them, anyway.

Comment by Andrea Martines — May 10, 2005

It’s not about ignoring an issue or expending “minimum effort.” It’s about being a pragmatist. Pragmatists and perfectionists might as well be Jews and Muslims for argument’s sake, but neither one is solely right. (As you can probably tell, I’m a pragmatist).

Comment by Peter Cooper — June 8, 2005

“…Jews and Muslims for argument’s sake, but neither one is solely right….”

That’s *your* opinion, bud. Islam is an objectively false “religion”, which has been warlike since its inception by the false “prophet”. Not that Israel, the nation, has been blameless in its conduct…but as for theology…they were the chosen people of God, and given that land.

Comment by LikeHellYouAre — January 9, 2007

Leave a comment

You must be logged in to post a comment.