Mark DiMarco

UI Developer at Bazaarvoice

jQuery .live() Gotchya

I was recently trying to fix a bug somebody introduced in our app, and after a bunch of digging I found the misunderstanding of $

tldr: cacheing a selector, then attaching a $ event listener, then attempting to use that cached selector (accessed via closure) can break.

The cached selector is not live, but attaching the event handler via $ works.

For this to work as expected, you’d have to do a re-selection within the event handler, instead of trying to use a cached selector.

Good thing that $ is deprecated as of jQuery 1.7