Low Pro for jQuery
Date : 2008 02 04 Category : Tech & DevelopmentDan 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
PLAIN TEXT JAVASCRIPT:Draggable = $.klass({ initialize: function(options) { }, onmousedown: function() {} }); GhostedDraggable = $.klass(Draggable, { onmousedown: function($super) { // do extra stuff here then call original method... $super(); } });
Attach behaviour
PLAIN TEXT JAVASCRIPT:$('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!