I am a newbie on web development, just started learning ajax request and dynamic content creation.
I have no problem in loading and parsing data. After loading data, Dynamically I create multiple rows represent each element of array (response of ajax request):
for(var i=0; i< dicts.length; i++){
var dict = dicts[i];
div_content += "<div id='row' " +
"onclick='callJs("+ dict.get('itemId') +");'>" +
<b>" + dict.get('name').toUpperCase()+ "</b> "+
dict.get('itemId') + " " +
dict.get('active_deals') + " DEAL <br/>" +
dict.get('popularity') + ". POPULAR BRAND <br/>" +
"<img src='resources/list_break.png' /><br/>" +
"</div>";
}
dict.get('itemId') is Long(26 digits) as a string. When I click a row, 'callJs' function fires, but a strange issue happens. My Long as a string becomes a Long, for example :
row id --> 85511111031103236921544356 ,
in function I see, row id --> 8551111103110325e+25
my string turns into a Long, I cannot understand. I also checked that my parser returns right value. I think dynamically created row's click function converts string to long.
function callJs(itemId) {
alert(itemId); // prints 8551111103110325e+25
alert(itemId.toString()); // prints 8551111103110325e+25
}
As you see, in iterator loop, I print itemId of each row, prints right value (85511111031103236921544356):

I could not find any solution anywhere. I wanna pass the id of each row to my function.
Any solution make me so glad..
Thanks in advance..