0

When i click in the div that had the event click event added, the array function is correctly executed but when the code try to access for example to the variable projetos[i].albumXML, the variable projetos seems not exists (undefined). The projectos variable is passed in the main function.

See the code bellow to understand better my problem:

function (...){
var projectClickFuncitons = [];

//do stuff

for (var i = 0; i < projetos.length; i++) {

    //do stuff

    projectClickFuncitons[i] = function () {
        LoadSavedProject(projetos[i].albumXML, projetos[i].pagesXML,
         projetos[i].idProject, codProjeto, projetos[i].projectShared, projetos[i].projectLocked,
         projetos[i].idCustomerLocked, projetos[i].idShareLocked, currentCustomerID,
         projetos[i].projectDomain, projetos[i].projectStorage, projetos[i].shareCustomerID);
    }

    //do stuff

}

//append html code

$(".openProject").each(function(){
    var position = parseInt($(this).attr("id").replace("openProject", ""));
    $(this).click(function () {
        projectClickFuncitons[position](position);
    });
});
}
Ricardo Rocha
  • 14,612
  • 20
  • 74
  • 130

0 Answers0