Is there a way of receiving all elements which have a oncontextmenu event assign开发者_StackOverflow中文版ed for dijit.Menu? Or is there any event when an new dijit.Menu is assinged to a HTML element?
I think this will work:
var contextMap = {}
dojo.provide('menu');
dojo.declare('menu', [dijit.Menu] , {
bindDomNode : function(a,b,c){
this.inherited(arguments);
contextMap[a] = this;
console.log(contextMap)
}
})
Updated Solution by powtac:
This works! I run this before the menus are instantiated. The trick is to use the same superClass as className, in this case 'dijit.Menu'
as string.
dojo.ready(function() {
dojo.declare('dijit.Menu', [dijit.Menu], {
bindDomNode: function(a,b,c) {
this.inherited(arguments);
console.log(a);
},
})
})
// ...
menu = new dijit.Menu( ... ); // when called the the event is caught
// and runs into the console.log(a);
Why look through the DOM looking for things that have things attached when you could just look through all the dijit.Menu widgets?
You could also easily extend the dijit.Menu widget and add a custom signal as part of the widget create process.
精彩评论