Wednesday, September 6th, 2006

Low Pro – Unobtrusive Scripting for Prototype

Category: Library, Prototype, Rails

We’ve covered the very cool UJS (Unobtrusive Javascript) plugin for Rails previously. Now the creators have extracted the javascript pieces to allow easy unobtrusive scripting with prototype and released it as Low Pro (download here). Low Pro features code from folks like Dean Edwards and Justin Palmer, among others. Its compatible with Prototype 1.5 and adds or enhances functionality without breaking backwards compatibility.

The library adds the following:

  • handy DOM navigation functions to elements – ex:

    1. $('widget').nextElement();    $('converge').replace(element)
  • a prototype friendly version of DOM Builder
  • replaces Event.observe and Event.stopObserving with Dean Edwards addEvent and removeEvent routines.
  • Declarative behaviors via Event.addBehavior(), including an OO approach where you create Behavior “classes” which can then be attached to elements.
  • Optional usage of Sylvian Zimmer’s $$ optimization

All in all it looks like a great add on to prototype – my only wish is that some of this stuff looks like it should be in the main code base, and not a third party add-on!

Posted by Rob Sanheim at 7:30 am

3.7 rating from 16 votes


Comments feed TrackBack URI

did you mean to say ‘WITH’ breaking backwards compat????

Comment by Mario — September 6, 2006

Thanks Mario, I fixed that.

Comment by Rob Sanheim — September 6, 2006

Some of their methods are covered in the V1.5.0_rc1 of Prototype.
I really like their Event mods and trigger method. The $ shortcuts = pretty cool but that kinda stuff can get out of control.. I have chossen a different approach in making an ‘onReady’. I use Event.observe, but make it handle the Event.observe(‘DOMContentLoaded’,….); just like mozilla/opera 9 do.

Comment by Mario — September 6, 2006

DOM navigation convenience methods actually ARE in the main codebase as of yesterday, aren’t they?

Comment by henrah — September 6, 2006

it breaks with the JSON library from – the Event.observe code includes some circular reference somewhere which throws json.js into a fit of recursion.

Comment by tom — October 20, 2006

Leave a comment

You must be logged in to post a comment.