javascript - Set the ID of View and TextView in titanium appacelerator -
i'm creating create randomly textareas need know textarea pressed user.
is there way enter unique id each textarea?
how create textview:
var txtarea = ti.ui.createtextarea({ color : '#000', backgroundcolor : 'transparent', font: { fontsize : 28, fontweight : 'normal', }, editable : false, textalign : 'left', value : a[i], textalign : 'center', top : '30%', width : '100%', height : '100%' });
i tried put "id : i", textareas returned same id.
it's not suggested add custom properties titanium proxies. here (based on guess of try achieve):
for(var = 0; < 10; i++){ var txtarea = ti.ui.createtextarea({ value : "test n " + i, textalign : 'left', textalign : 'center', top : '30%', width : '100%', height : '100%' }); (function(){ var id = i; txtarea.addeventlistener('click',function(){ console.log(id); }); })(); }
Comments
Post a Comment