Skip to content

Instantly share code, notes, and snippets.

@markmarkoh
Created April 27, 2012 17:59
Show Gist options
  • Save markmarkoh/2511352 to your computer and use it in GitHub Desktop.
Save markmarkoh/2511352 to your computer and use it in GitHub Desktop.
$.fn.live mishap
// $.fn.live misuse
(function() {
// cache all elements that match this selector *as they exist on the page right now*
// let's say this is empty at this point in time
var $posts = $(".posts");
// set up a click listener. this is totally valid with $.fn.live,
// any new ".posts" that get added to the DOM will automatically respond to this
$posts.live('click', function() {
//update all the HTML of all the ".posts", this selector is still *EMPTY*
$posts.html("this doesn't work the way you might expect");
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment