PDA

View Full Version : Dynamic Menu Handler Problem



renganathan
17 Aug 2012, 5:46 AM
Hi All,

I have dynamically creating the menu .Its working fine with the following code

But the problem is ,

In handler i am calling some function based on the menu selection. I am passing the menu value as a parameter to the function .

First time the some value has been selected , that value is retaining forever .i mean even if i select another value only the first selected value is always passed in the function.

Can you guys suggests where i am doing wrong?

Please refer the following code




//tbname is an array holds the values value1,value 2, value 3 and value 4
var tblen = tbname.length;
var tn= '';
for(var y=0; y<tblen; y++)
{
tn = tbname[y]
addMenu.add
(
{
text:tn ,
checked: false,
group: 'theme',
handler : function()
{
callFunction(tn);
}
}
)
}
addMenu.doLayout();


38035

vietits
17 Aug 2012, 6:30 AM
Try this:


var tblen = tbname.length;
var tn= '';
for(var y=0; y<tblen; y++) {
tn = tbname[y]
addMenu.add({
text:tn ,
checked: false,
group: 'theme',
handler: function(button){
callFunction(button.text);
}
});
}

renganathan
17 Aug 2012, 6:52 AM
Thanks for your help

I really appreciate your effort