0

I am creating a dynamic context menu and as it is expected I would like to menu to be closed when the mouse leaves the menu box. I have used :

var dlg = new dijit.Menu({                   
         onMouseLeave: function(event){
        dijit.popup.close(dlg);
    }
});

But when i go out side the box nothing happens. If I put same function inside the MenuItems then when I leave the MenuItem box it closes the box.

Any comment?

user1372020
  • 91
  • 2
  • 2
  • 12

1 Answers1

2

This would be because the dijit.Menu does not register onMouseLeave on its domNode.

To do this manually, following is all you need: (havent sampled a test though should work)

var myconnects = []
var dlg = new dijit.Menu({                   
   destroy: function() {  // for a neat garbage collections, remove listeners
      var ch;
      while(ch = myconnects.pop()) ch.disconnect();
      this.inherited();
   }
   ...
});
myconnects.push(dojo.connect(dlg.domNode, "onmouseleave", dojo.hitch(dlg, function() {
    dijit.popup.close(this);
});
mschr
  • 8,531
  • 3
  • 21
  • 35