我正在为slickgrid做一个自定义编辑器,虽然我怀疑我在这种情况下确实非常重要。所以我们可以说我有这样的事情隐约设置:调用绑定到来自绑定到事件的另一个函数的事件的函数不起作用
function TestEditor(args) {
var $test0, $test1;
//other variables
this.init = function() {
//various init stuff, it all works fine
//init $test0 and $test1, also works fine
$test0.bind("change", this.test0Changed);
$test1.bind("change", this.test1Changed);
this.test0Changed(); //this works fine too, makes the nested call to test1Changed
}
this.test0Changed = function() {
//does various operations
this.test1Changed(); //calls test1Changed, this works _unless_ test0Changed is called through an event, then the code breaks here!
//stuff that won't happen when the code breaks at the previous call
}
this.test1Changed = function() {
//stuff, works fine unless called by test0Changed triggered by an event, then nothing
}
//whatever, lots of other stuff, it all works
this.init();
}
我想test0Changed做出test1Changed打电话,如果我明确地在代码中的调用自己this.test0Changed(),它工作正常。但是当test0Changed被'change'事件触发时,代码在试图调用this.test1Changed()时会中断。如果我注释掉对this.test1Changed()的调用,一切都很好,所以我知道是导致问题的那条精确线。这是什么造成的?
什么'测试变量在虚线上注明? – paislee 2012-02-14 17:46:06
哎呀,这是愚蠢的,我的意思是这个 – user173342 2012-02-14 17:47:19