Closed fr3em1nd closed 10 years ago
How exactly are you assigning dynamic id's? Here are a few ways to do exactly that
Generate the unquie id in JSON and just use it in the div as the id
{"tag":"div","id":"${someUniqueID}"}
Use the index of the object in the array being transformed
{"tag":"div","id":function(obj,index) {
return("div" + index);
}}
OR make up a unquie id on the spot
function guid() {
function s4() {
return Math.floor((1 + Math.random()) * 0x10000)
.toString(16)
.substring(1);
}
return s4() + s4() + '-' + s4() + '-' + s4() + '-' +
s4() + '-' + s4() + s4() + s4();
}
{"tag":"div","id":function() {return guid();}}
this helped thank you
hi i get error on assigning dynamic ids on divs from the json data passed. this is useful for creating individual function for each divs