Try this :
deCarta.Core.EventManager.listen('click',
(function(id) { return function (){home.pinPushed(id);}})(device.id), device.pin);
Beautify version :
deCarta.Core.EventManager.listen('click', (function (id)
{
return function ()
{
home.pinPushed(id); //<---- id here is the closured variable
}
})(device.id), device.pin);
Explanation :
Js
has a function scope ( not braces ({})
scope.)
Your for
loop is not creating ANY scope/function.
What I was doing is to create execution context for each iteration.
for each iteration im sending the current device.id
to a function which in turn , returns another function which closured the variable.