News for hackers. Stuff that matters.
Re:JQuery 1.8b1: what’s new? by gildas on Saturday June 23, 2012 @06:28AM (#4150536)
Binding event handlers in a loop is an anti-pattern greatly promoted by jQuery during several years. You should use event delegation.
Re:JQuery 1.8b1: what’s new? by mark_story on Saturday June 23, 2012 @11:42AM (#4151041)
Sure but $('.clicky').on('click', doSomething); means no loops at all, and will bind events to all matching elements. I don't think there is a native API way to do this.

Edit: typos

Re:JQuery 1.8b1: what’s new? by gildas on Saturday June 23, 2012 @08:19PM (#4152198)
As far as I know jQuery is written with "native API", so there is obviously a way to do this in JavaScript.

    document.body.addEventListener("click", function(e) { 
      if (e.target.className == "clicky") {
        doSomething();
      }
    }, false);
Re:JQuery 1.8b1: what’s new? by MatthewPhillips on Saturday June 23, 2012 @05:11PM (#4151812)
document.getElementsByClassName('clicky').forEach(function(el) { el.addEventListener('click', doSomething); });
Re:JQuery 1.8b1: what’s new? by d4n3 on Sunday June 24, 2012 @03:53AM (#4152864)
I'm not sure that works. getElementsByClassName (and Id and querySelector) returns a NodeList, not an Array, so there's no foreach, you have to convert it to an array first.
Re:JQuery 1.8b1: what’s new? by MatthewPhillips on Sunday June 24, 2012 @09:02AM (#4153230)
Array.prototype.slice.call(document.getElementsBy....
Re:JQuery 1.8b1: what’s new? by mark_story on Wednesday June 27, 2012 @08:27PM (#4169901)
That's also a ton of tying and a lot of code that a minifier can't reduce. I guess its possible, but do you really want to writing such verbose code?