Backtype.com/emjayess

Syndicate content
Feed provided by BackType.com
Updated: 1 year 46 weeks ago

jQuery code smells

Wed, 01/06/2010 - 12:21

alternatively, if there are going to be a ton of anchors, then registering click handlers on all them can become an inconsiderate resource hawg — so you might instead choose to register just a single click handler on a wrapper element, and then only perform some logic if the event target is an anchor you are interested in adding behavior to.

Read more comments by matt j. sorenson

jQuery code smells

Wed, 01/06/2010 - 12:14

If anchors are continually being added to the page after “ready”, and you need to handle events on them… you can use:

var anchors = $('a');anchors.live('click',function(){ anchors.not(this).addClass('wow');});

so, you still have no excuse for not caching DOM selections in the case of event handling.

Read more comments by matt j. sorenson