Created
April 22, 2016 15:03
-
-
Save anonymous/484e30d2c931f165fbc4d30666a84b69 to your computer and use it in GitHub Desktop.
Proxy demo $.proxy event handlers demo // source http://jsbin.com/zomipo
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> | |
<head> | |
<meta name="description" content="$.proxy event handlers demo"> | |
<script src="https://code.jquery.com/jquery-3.0.0-alpha1.js"></script> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width"> | |
<title>Proxy demo</title> | |
</head> | |
<body> | |
<h1>Proxy Demo</h1> | |
<input type="button" id="clickme" value="click me" /> | |
<script id="jsbin-javascript"> | |
var eventHandlers = { | |
type: 'My Event Handler Object', | |
clickButtonHandler: function(event) { | |
console.log(this.type); | |
} | |
}; | |
$(function() { | |
//$('#clickme').click(eventHandlers.clickButtonHandler); | |
$('#clickme').click($.proxy(eventHandlers.clickButtonHandler, eventHandlers)); | |
}); | |
</script> | |
<script id="jsbin-source-javascript" type="text/javascript">var eventHandlers = { | |
type: 'My Event Handler Object', | |
clickButtonHandler: function(event) { | |
console.log(this.type); | |
} | |
}; | |
$(function() { | |
//$('#clickme').click(eventHandlers.clickButtonHandler); | |
$('#clickme').click($.proxy(eventHandlers.clickButtonHandler, eventHandlers)); | |
});</script></body> | |
</html> |
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
var eventHandlers = { | |
type: 'My Event Handler Object', | |
clickButtonHandler: function(event) { | |
console.log(this.type); | |
} | |
}; | |
$(function() { | |
//$('#clickme').click(eventHandlers.clickButtonHandler); | |
$('#clickme').click($.proxy(eventHandlers.clickButtonHandler, eventHandlers)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment