这是一个简化版本。
如果我这样做:
var object = [{name:"bob", type:"silly", hair:"brown", func:someFunction},
{name:"greg", type:"serious", hair:"blonde", func: differentFunction}];
$('#thing').bind("click", object[0], handleTranslator);
function handleTranslator(e){
$([e.data.func]);
}
function someFunction(){
console.log("clicking bob should trigger this function");
}
function differentFunction(){
console.log("clicking greg should trigger this function");
}
当我点击#thing时,它应该触发someFunction
,但事实并非如此。不知道为什么。
理想情况下,我还希望能够从someFunction
内看到(console.log)我的对象[0]。
感谢您的帮助。
答案 0 :(得分:1)