android - View is not updating from other controller Appcelerator Alloy -
i hope fine. having trouble updating views in titanium appcelerator alloy,
i want able delete previous children picker , add new 1 in picker in different controller/view in.....
i have followed this solution unfortunately not working me. here code trying.
createevent.js
ti.app.addeventlistener('db_update', function(){ alert("ok"); $.picker.removeallchildren(); })
customparty.js
$.btnclick.addeventlistener('click', function(){ ti.app.fireevent('db_update'); }); // ok alert shows children of picker aren't removed.
since ok alert shown, in way , callback function called successfully. problem here calling removeallchildren
method not removing rows picker. solution iterate on colums , delete rows :
ti.app.addeventlistener('db_update', function(){ alert("ok"); //get picker columns var columns=$.picker.getcolumns(); //iterate on picker columns (var it=0,length=columns.length;i<length;it++){ //iterate on column rows if(columns[it]){ var len = col.rowcount; for(var index=0,collength=columns[it].length;index<collength;index++){ //remove rows[index] of columns[it] columns[it].removerow(columns[it].rows[index]); } } } });
by way applcelerator's folks said using global events (ti.app events) may cause problems in memory managements...
keep in mind app-level events global, means remain in context entire time app running (unless remove them). means objects reference remain in scope while app runs. prevent objects being garbage collected.appcelerator gays.
another method use global functions:
in first view controller (where picker defined):
alloy.globals.removeallpickerchildren=function(){ //do want here };
then in seconde viewcontroller:
$.btnclick.addeventlistener('click', function(){ if(alloy.globals.removeallpickerchildren) alloy.globals.removeallpickerchildren(); });
Comments
Post a Comment