Skip to content

Instantly share code, notes, and snippets.

@jo
Created January 6, 2011 11:37
Show Gist options
  • Save jo/767791 to your computer and use it in GitHub Desktop.
Save jo/767791 to your computer and use it in GitHub Desktop.
Testing bind event persistence over DOM removal
<!doctype html>
<html lang=en>
<head>
<meta charset=utf-8>
<title>Backbone Event Delegation Tests</title>
<script src="http://documentcloud.github.com/backbone/test/vendor/jquery-1.4.2.js"></script>
<script>
$(function() {
var main = $('#main'),
el = $('<p>Welcome <a href="#">Please click me</a></p>');
el.delegate('a', 'click', function() {
$(this).append(' clicked');
});
main.html(el);
main.html('');
main.html(el);
});
</script>
</head>
<body>
<article>
<h1>Backbone Event Delegation Tests</h1>
<p>click the text below. Nothing should happen.</p>
<div id=main>initial content</div>
</article>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment