PDA

View Full Version : Aid for javascript syntax



wki01
24 Jun 2009, 5:11 AM
I realize that my knowledge of javascript is very poor...
So it works:


tbar.add({
text: 'Configura',
icon: Application.httpUrl + "/" + 'wki.setting.24x24.png',
scale: 'medium',
cls: 'x-btn-text-icon',
handler: function(){
}
},{
text: 'Spedisci',
icon: Application.httpUrl + "/" +'wki.send.24x24.png',
scale: 'medium',
disabled: true,
cls: 'x-btn-text-icon'
})
So it does not work


var x = [{
text: 'Configura',
icon: Application.httpUrl + "/" + 'wki.setting.24x24.png',
scale: 'medium',
cls: 'x-btn-text-icon',
handler: function(){
}
},{
text: 'Spedisci',
icon: Application.httpUrl + "/" +'wki.send.24x24.png',
scale: 'medium',
disabled: true,
cls: 'x-btn-text-icon'
}]
tbar.add(x)

where I go wrong?
Thank you

exo
24 Jun 2009, 5:23 AM
There's nothing wrong with your JS I think, however, the 'add' method does not accept an array (see: http://extjs.com/deploy/ext-3.0-rc1/docs/output/Ext.Toolbar.html).

You could try this:


var x = [{
text: 'Configura',
icon: Application.httpUrl + "/" + 'wki.setting.24x24.png',
scale: 'medium',
cls: 'x-btn-text-icon',
handler: function(){
}
},{
text: 'Spedisci',
icon: Application.httpUrl + "/" +'wki.send.24x24.png',
scale: 'medium',
disabled: true,
cls: 'x-btn-text-icon'
}]
tbar.add.apply(tbar, x)

Condor
24 Jun 2009, 5:23 AM
In Ext 2.x Toolbar.add doesn't support an array parameter. It does however support multiple parameters, e.g.

tbar.add.apply(tbar, x);
which is the same as calling:

tbar.add(x[0], x[1], ...);

ps. In Ext 3.x Toolbar.add also supports an array parameter.

wki01
24 Jun 2009, 5:29 AM
ps. In Ext 3.x Toolbar.add also supports an array parameter.

Thank you!
Now I'm using Ext 3.0rc2.
The feature will be in the final version?