Created
January 23, 2010 04:06
-
-
Save ironsjp/284417 to your computer and use it in GitHub Desktop.
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
function createHandler(fn, obj) { | |
return function(){ fn.apply(obj, arguments) }; | |
} | |
function a(e) { | |
console.log(this.a, e.clientX); | |
} | |
function b(e) { | |
console.log(this.b, e.clientX); | |
} | |
function c(e) { | |
console.log(this.c, e.clientX); | |
} | |
var obj = {a:"a", b:"a", c:"c"}; | |
var handlera = createHandler(a, obj); | |
var handlera2 = createHandler(a, obj); | |
var handlerb = createHandler(b, obj); | |
var handlerc = createHandler(c, obj); | |
$(document).bind('click',handlera); | |
$(document).bind('click',handlera2); | |
$(document).bind('click',handlerb); | |
$(document).bind('click',handlerc); | |
$(document).unbind('click',handlera); | |
$(document).unbind('click',handlerb); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment