I have a tree widget on one of my CMPs. The basic functionality is copied from the Gallery component.
Tariffs.tree.Tariffs = function(config) {
config = config || {};
Ext.applyIf(config,{
id: 'tariffs-tree-tariffs'
,url: Tariffs.config.connector_url
,action: 'mgr/tariff/getNodes'
,root: {
nodeType: 'async',
leaf: false,
text: 'All Tariffs',
id: 'root'
}
,tbar: [{
text: _('tariffs.tariff_create')
,handler: function(btn,e) { this.createTariff(btn,e,true); }
,scope: this
},'-',{
text: _('tariffs.refresh')
,handler: this.refresh
,scope: this
}]
,rootVisible: true
})
Tariffs.tree.Tariffs.superclass.constructor.call(this,config);
};
At the lowest level of the tree are Tariff object which I would like to update / delete by right clicking on an entry.
I added this in the definition of each Tariff node which is assembled by a PHP snippet:
$node = new TreeNode();
$node->menu['items'][] = array(
'text' => $modx->lexicon('tariffs.tariff_update'),
'handler' => 'function(itm,e) { this.updateTariff(itm,e); }',);
$node->menu['items'][] = '-';
$node->menu['items'][] = array(
'text' => $modx->lexicon('tariffs.tariff_remove'),
'handler' => 'function(itm,e) { this.removeTariff(itm,e); }',);
In the definition of the tree widget I have the following definition for the updateTariff function:
Ext.extend(Tariffs.tree.Tariffs,MODx.tree.Tree,{
windows: {}
,updateTariff: function(btn,e) {
alert("about to update a tariff record");
}
....
Now the menu pops up correctly when a right click a node, however when I select the "Update" option I don’t see the alert as I would expect.
What am I doing wrong??
Thanks!