Erroneous handling of floor
asm0dey opened this issue · 4 comments
asm0dey commented
Code like
for (i = _i = 0, _len = floors.length; _i < _len; i = ++_i) {
floor = floors[i];
floor.on('up_button_pressed down_button_pressed', function(event) {
console.log(event)
console.log(i)
activeFloors.push(i);
});
}
reports one floor every time. In my case it's 8
asm0dey commented
Looks like all events are being binded to one floor
marado commented
No, your iterator is the one that reports '8'. You shouldn't be using 'i'
in the event handler function, try 'this' to get the floor object instead
On Jan 26, 2015 6:25 AM, "Paul" notifications@github.com wrote:
Looks like all events are being binded to one floor
—
Reply to this email directly or view it on GitHub
#42 (comment).
asm0dey commented
You're right, this works. But it looks like strange behaviour for me. Binding event listener isn't async action, is it?