Message from discussion
Prototype + lowpro vs. JQuery
Received: by 10.35.14.4 with SMTP id r4mr3629685pyi.2.1201357812691;
Sat, 26 Jan 2008 06:30:12 -0800 (PST)
Return-Path: <d...@danwebb.net>
Received: from hs-out-2122.google.com (hs-out-0708.google.com [64.233.178.246])
by mx.google.com with ESMTP id x46si3804679pyg.3.2008.01.26.06.30.12;
Sat, 26 Jan 2008 06:30:12 -0800 (PST)
Received-SPF: neutral (google.com: 64.233.178.246 is neither permitted nor denied by best guess record for domain of d...@danwebb.net) client-ip=64.233.178.246;
Authentication-Results: mx.google.com; spf=neutral (google.com: 64.233.178.246 is neither permitted nor denied by best guess record for domain of d...@danwebb.net) smtp.mail=...@danwebb.net
Received: by hs-out-2122.google.com with SMTP id 23so971372hsn.6
for <low-pro@googlegroups.com>; Sat, 26 Jan 2008 06:30:12 -0800 (PST)
Received: by 10.151.15.3 with SMTP id s3mr1345454ybi.29.1201357812044;
Sat, 26 Jan 2008 06:30:12 -0800 (PST)
Received: by 10.150.181.7 with HTTP; Sat, 26 Jan 2008 06:30:11 -0800 (PST)
Message-ID: <5b3e279f0801260630i58a84ef2u336f161f17d78ab6@mail.gmail.com>
Date: Sat, 26 Jan 2008 14:30:11 +0000
From: "Dan Webb" <d...@danwebb.net>
To: low-pro@googlegroups.com
Subject: Re: Prototype + lowpro vs. JQuery
In-Reply-To: <5b3e279f0801260204o7e8ecb37qd6c994c071274fad@mail.gmail.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
References: <102c1a64-c792-46f5-95d0-202ce9fdbe3c@j78g2000hsd.googlegroups.com>
<bb99361a0801211126k2df88416h68021d8a797c3f0b@mail.gmail.com>
<f58d8dcb0801211358w51dadccdgc838fb1a6abd11e6@mail.gmail.com>
<5b3e279f0801251922g20060bfbxbf536db9cb41d802@mail.gmail.com>
<f58d8dcb0801251938r688da9fex9992160b1b1ff195@mail.gmail.com>
<5b3e279f0801260204o7e8ecb37qd6c994c071274fad@mail.gmail.com>
On 1/26/08, Dan Webb <d...@danwebb.net> wrote:
> I'll see what I can put together.
We'll I've made a start and I must stay it works really nicely with jQuery.
http://svn.danwebb.net/external/lowpro-jq/trunk
Warning: I've literally just bashed this out so its not ready for
usage but you can get an idea of how it goes together by looking at:
http://svn.danwebb.net/external/lowpro-jq/trunk/test/test.html
But the rundown is...
Create a behavior as a class:
Testy = $.klass({
initialize: function(arg) {
alert('ive just been attached with the arg ' + arg);
},
onclick: function() {
alert('ive been clicked');
}
});
Btw, $.klass is a full port of the Prototype Class.create stuff so you
get that as a bonus and can use all the inheritance stuff in the same
way.
Then attach it on ready in the jQuery way:
jQuery(function($) {
$('p').attach(Testy, 'My arg');
});
And that's it. Works the same for this point on.
Another little bonus is that if you are running livequery it does some
magic and automagically attaches new instances of the behaviour
whenever the DOM is changed so for the above example if you
$(document.body).append('<p>Another para</p>') then it gets its own
behavior instance as well.
So, I think it needs some more bashing (and some unit tests) and I
think it would be good to ship with some behaviors like normal Low Pro
does. Probably Remote and Observed...
What do ya'll think? After sitting and coding it Im actually really
pleased with how it turned out. It's much simpler than the Prototype
implementation and fits jquery's style a lot more. I might defect :)
Cheers,
Dan
--
Dan Webb
http://www.danwebb.net
aim: danwrong123
skype: danwrong