Wednesday, September 6th, 2006
Low Pro – Unobtrusive Scripting for Prototype
<p>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:
JAVASCRIPT:
-
$('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!
Related Content:











did you mean to say ‘WITH’ breaking backwards compat????
Thanks Mario, I fixed that.
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.
DOM navigation convenience methods actually ARE in the main codebase as of yesterday, aren’t they?
it breaks with the JSON library from json.org – the Event.observe code includes some circular reference somewhere which throws json.js into a fit of recursion.