Possible Duplicate:
Javascript closure inside loops - simple practical example
Please explain the use of JavaScript closures in loops
for (var i = 0; i < pois.length; i++) {
    pois[i].marker.addEventListener('dblclick', function (data) {
        var infoWindow = new BMap.InfoWindow(pois[i].address, opts);  
        map.openInfoWindow(infoWindow, map.getCenter());     
    })
}
this is my code.
obviously there is an error at here 
new BMap.InfoWindow(pois[i].address, opts);
how can I use pois[i].address in pois[i].marker listener function ?
 
     
    