javascript - Uncaught illegal access while adding element in array -
here javascript
function:
note: resultarray
defined in calling function var resultarray = [];
onaddelement : function (win,id,resultarray) { var controller = this; if(!win.flag){ ext.messagebox.show({ title: 'yes or no', icon: ext.messagebox.question, msg: 'do want continue?', buttontext: {yes:'yes', no:'no', cancel:'cancel', fn: function (me) { if(me === 'yes'){ ver = win.curver; resultarray.push({ id: id, ver: ver }); controller.anotherfunc(win,id); }else if(me === 'no'){ ver = win.ver; resultarray.push({ id: id, ver: ver }); controller.anotherfunc(win,id); } } }); }else{ ver = win.ver; resultarray.push({ //getting uncaught illegal access id: id, ver: ver }); controller.anotherfunc(win,id); } }
i have made comment on line getting uncaught illegal access
error. unable find root cause of it.
i got solution it. need define resultarray
function , if needed values argument array can assigned array defined function.
here modification:
onaddelement : function (win,id,argarray) { var resultarray = []; // define array inside function resultarray = argarray; // if required assign arg array local array. var controller = this; . . . . }
Comments
Post a Comment