Skip to content

Instantly share code, notes, and snippets.

@mannuelf
Forked from anonymous/index.html
Created April 22, 2016 15:03
Show Gist options
  • Save mannuelf/065c8968b377bd84ffbeee1af4f855b1 to your computer and use it in GitHub Desktop.
Save mannuelf/065c8968b377bd84ffbeee1af4f855b1 to your computer and use it in GitHub Desktop.
Proxy demo $.proxy event handlers demo // source http://jsbin.com/zomipo
<!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>
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