Created
January 6, 2011 11:37
-
-
Save jo/767791 to your computer and use it in GitHub Desktop.
Testing bind event persistence over DOM removal
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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