When you use Javascript inline in HTML that way you’re limited. It would be better to create the object with Javascript and join an event receiver where you can pass the type of object you want.
Notice there’s another problem here that the bfavaretto noticed and I did not. You can read more about the problem here, but deep down i
must be stored in memory so that it is not overwritten by the loop.
So I suggest something of the style:
var botaoMaisInformacoes = document.createElement('button');
(function(){
var index = i;
botaoMaisInformacoes.addEventListener('click', function(){
popularEdicaoRetrofit(data[i]);
});
})();
instead of onclick = "popularEdicaoRetrofit(\''+data[i]+'\');"
However if you are using Objects that can be converted to JSON you can do
`onclick = "popularEdicaoRetrofit(\'' + JSON.stringify(data[i]) + '\');"`
So the object is passed as JSON/string and inside the function you only have to do
var objeto = JSON.parse(dataString);
Could you please post the code of what you have done so far?
– PauloHDSousa
Felipe, please post the code as text (then select and type CTRL+K to format as code).
– bfavaretto