1

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)

1 Answers1

0

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
    }
}));
jason0x43
  • 3,363
  • 1
  • 16
  • 15
  • that still returned part of the menu for me....it must be something to do with how they build their tabcontainer and associate menus to it. Anyway, it gave me the idea of drilling up the parentNode's until I got to their popup, and then from there into the tab that was selected. Thanks! – Andrew Wylie Apr 15 '15 at 19:07
  • But how to get the "closeMenu" in code above? I can not find any clue in doc or google.Please help me. – hardPass Nov 22 '15 at 07:48