【发布时间】:2013-09-23 08:30:39
【问题描述】:
我有以下代码在页面中的每个按钮上调用一个函数。
dojo.query('.btn').forEach(function(item){
Obj = new MyClass(item); // class calls the ajax request on error of each btn click I have to handle some functionality in below function showError
dojo.connect(Obj, 'showError', dojo.hitch(Obj, function(errors){
console.log(Obj + 'came');
}));
这里我尝试使用dojo.hitch来维护每个对象Obj的状态,但它没有维护。只有第一个Obj在触发。对于第二个Button,第一个Obj也在触发。这里有什么我遗漏的吗。
【问题讨论】:
-
您是否检查过您的 forEachLoop 是否提交了正确的项目?它会循环穿过您制作的一堆 Button,还是会在第一个按钮处中断?
标签: javascript html events dojo dom-events