« Squeezebox network music player | Main | Some AJAX issues and some workarounds »

November 10, 2005

AJAX and Prototype

I've been doing a lot of DHTML Javascript and AJAX stuff for work lately. I was using my own library of AJAX functions, and an odd assortment DOM/Element modifying scripts. These methods actually worked quite well, but they seemed a bit disjointed. I recently discovered the Prototype Javascript Framework, and I'm really impressed. I was able to refactor my AJAX code to use Prototype in about 30 minutes. Prototype also offers a bunch of really slick DOM insertion methods that allow you to insert a block of code wherever you want in the DOM with ease. Adding event listeners also seems to be pretty easy. Here are two simple but fantastic shortcuts provided by Prototype:
$("elementid") is the same as document.getElementById("elementid")
$F("elementid") is the same as document.getElementById("elementid").value

The framework page itself has little in the way of documentation. Thankfully, I did find this document which outlines the framework, and shows some examples of use. I've also looked at the Prototype source javascript and it's remarkably clear.

The framework is in production use within the Ruby On Rails framework, so while I'm not a javascript guru by any means, I'm confident that it's sound code, and isn't going anywhere. I highly recommend checking it out.

Posted by mark at November 10, 2005 4:11 PM Subscribe (FeedBurner)

Comments

Post a comment




Remember Me?

(you may use HTML tags for style)