Re:Differences Between jQuery .bind() vs .live() vs .delegat...
by rimantas on Monday February 06, 2012 @12:38PM
(#3558296)
I think you misread this. It does not bind the same instance of the handler to each element. Each element gets its own copy of this handler, hence the waste of memory.
Re:Differences Between jQuery .bind() vs .live() vs .delegat...
by dcher on Monday February 06, 2012 @02:13PM
(#3558739)
What? No they don't, unless you're making the handler in a loop.
$( "div" ).click( function() {} );
Each div will have the same handler applied, it doesn't make a new one for every div.
Re:Differences Between jQuery .bind() vs .live() vs .delegat...
by stephenr on Monday February 06, 2012 @09:35PM
(#3560180)
You're confusing the callback with the actual event listener.
Re:Differences Between jQuery .bind() vs .live() vs .delegat...
by spohlenz on Monday February 06, 2012 @08:41PM
(#3560057)
Compared to onclick, it's certainly a performance benefit.
However the difference here is in looping over every matched element to add the handler (bind) versus adding the handler to a single element further up the DOM tree (delegate).
Why is that a con for .bind()? This used to be considered a performance benefit compared to onclick.