Some people argued that one could do the same with something like:
var initEvents = function(behaviors){
/* Add behaviors to the document when it's ready */
$(document).ready(function(){
var ruleAndEvent, rule, event, key, fn;
for(key in behaviors){
fn = behaviors[key];
ruleAndEvent = key.split(":");
rule = ruleAndEvent[0];
event = ruleAndEvent[1];
$(rule)[event](fn);
}
});
}
You can use it like this:
initEvents({
'a.alert_hello_world:click': function(event){
alert("Hello World!"); event.preventDefault();
},
'p.hide_myself:click': function() {
// this refers to the paragraph being clicked
$(this).hide();
}
});
Chris from Err the blog, mentioned that he was excited about seeing LowPro
being ported to JQuery, he just whished you were using click instead of
onclick.
I'm personally really excited, especially with the new Merb release coming
up, I believe JQuery will grow in the Ruby community. I'll do my best to try
to see if I can come up with behaviors.
-Matt
On 1/28/08, Dan Webb <d...@danwebb.net> wrote:
> On 1/28/08, Peter <peter.kielt...@gmail.com> wrote:
> > ... I like jQuery, and I'd prefer to use it because of its adoption
> > and support, but from this small subset of a test, it does not perform
> > well at all. Reading the jQuery blog, they've taken on a developer to
> > optimize their code, I'm looking forward to seeing what they come up
> > with.
> From looking at that there's not a huge amount in it. In my
> experience, since all the selector engines jumped up in performance a
> while ago framework speed is not a problem. High performance is
> normally achieved at application level. Doing things like using event
> delegation, lazy evaluation and generally writing code in a way that
> makes for the least amount of work possible is what really counts.
> Even before the selector speed up it wasn't a huge problem - you just
> needed to be careful with what selectors you used. However, I say
> this from my experience. So although I work on a lot of pretty JS
> heavy applications I've never felt the need to write a raytracer in JS
> or something similar.
> But yeah, back to the original point. If you do like Mootools and
> want to port Low Pro then that would be cool. It's already got a
> class implementation which is most of what Low Pro JQ's code is so its
> probably going to be very simple to do.
> Cheers,
> --
> Dan Webb
> http://www.danwebb.net
> aim: danwrong123
> skype: danwrong