I'm a dojo newbie and I'm modifying an existing application for my customer and adding an extra options to the popup menu....'Close all', and 'Close other tabs'. There already exists 'Close'.
Adding the extra menu items were fairly straightforward...'Close all' gets the tabContainer and iterates over the tabs removing them.
But for 'Close other tabs', i.e. close all other tabs except the one I right-clicked on, I can't figure out how to get the id of that tab, on which the right-mouse click was done.
The 'selectedChildWidget' is not the tab I want, it gives the tab which is currently selected...I right clicked on one of the other non selected tabs.
Any ideas? I have the mouse event but cannot find the path back to the tab it was triggered against, only the popup menu.
Many thanks, Andrew (going rapidly grey over this one)
Dijit Menus have a currentTarget
property that indicates what node the menu is being displayed for. From a MenuItem's onClick
handler, you can access the current target node with this.getParent().currentTarget
:
closeMenu.addChild(new MenuItem({
label: 'Close all',
ownerDocument: document,
onClick: function (evt) {
// tab that was clicked
var tab = registry.byNode(this.getParent().currentTarget);
// tab's associated page is tab.page
}
}));