i. . for 8, ratings[8]. , :
for (i=0; i < 8; i++)
{
var idx = i;
$('#rate' + idx + '_wrapper a').click(function() {
ratings[idx] = parseInt( $(this).attr('id').split('_')[1] );
console.debug(ratings);
});
}
, var . , , idx . , , :
function CreateHandler(idx) {
return function() {
ratings[idx] = parseInt( $(this).attr('id').split('_')[1] );
console.debug(ratings);
}
}
for (i=0; i < 8; i++) {
$('#rate' + idx + '_wrapper a').click(CreateHandler(i));
}
, , . idx .