0

So I need to associate an event listener to execute the function I'm passing as argument on the onClick event. My issue is that every time it reaches onClick event, the argument is undefined, even if I associated the index with the new function!

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

        var widgetActiveTab = document.createElement('li');
        widgetActiveTab.className = "tabsList";
        widgetActiveTab.id = "li" + returnableInfo[i].id;

        var widgetTabContent = document.createElement('a');
        widgetTabContent.id = "li_a" + returnableInfo[i].id;




        function createfunc(i) {

            return returnableInfo[i];

        }

        params[i] = createfunc(i);



        widgetTabContent.addEventListener('click', function () {
            console.log(params[i]);

            executeIfFacetasSensoresResponseReady(params[i]);
        });

0 Answers0