Monday, February 4th, 2008
Low Pro for jQuery
Dan Webb has ported Low Pro to jQuery and along the way discusses differences between Prototype and jQuery:
The one big reason was that, while jQuery was super simple and concise when working on smaller projects, it offered no help in structuring larger applications. All you get in jQuery, aside from Ajax methods and a handful of utilities, is the ability to select nodes then doing something with them. On the other hand Prototype is much rounder in scope. It generally plumps out JavaScript as a language adding lots of useful methods to built-ins, a host of functional programming tools and recently a full Class-based OO system with inheritance and the whole shebang which has formed the back bone of Low Pro’s behavior classes.
Let's not get into that debate though, instead, lets just look at the port.
Create a class
-
-
Draggable = $.klass({
-
initialize: function(options) { },
-
onmousedown: function() {}
-
});
-
-
GhostedDraggable = $.klass(Draggable, {
-
onmousedown: function($super) {
-
// do extra stuff here then call original method...
-
$super();
-
}
-
});
-
Attach behaviour
-
-
$('div.product').attach(GhostedDraggable, { anOption: thing });
-
Also, if you are using livequery jLow (I had to use it Dan!) will play nicely and work as the DOM changes too!












Don’t get me wrong. I’m not trying to spark anymore pointless debate on which library is best at all. I like them both and I think that jQuery’s descision to be tight in scope is one of it’s strengths. I was just commenting on why I though it was worth porting Low Pro to jQuery and where it might fit in the jQuery landscape.
I love it. I’ve always wanted this in JQuery. I think as an add-on, it’s great.
One idea is that you can add functionality and hooks into plugins and jQuery objects instead of leaving it up to the plugin author to create those hooks, or creating your own plugin.