开发者

EXT JS - adding a listener on any element added to a container

开发者 https://www.devze.com 2023-02-05 15:19 出处:网络
HI, I have a ExtJS parent \'container\' type, whereas i need to add a \'contextmenu\' listener to any element that is added to this parent container, via Drag/Drop.

HI, I have a ExtJS parent 'container' type, whereas i need to add a 'contextmenu' listener to any element that is added to this parent container, via Drag/Drop. Can someone guide me as to the best way to do this?

I have tried this below but can't get the function to fire.

myContainer.on('added', fu开发者_开发问答nction(obj1,obj2,index){
   alert('added');
});

this may not be the 'best practice' to do it this way anyway...? thanks for the help !


You're using the wrong event... The added event gets fired when (using your example) myContainer is added to some other container. What you'll need is the add event that fires, when an item is added to myContainer:

myContainer.on('add', function(container, component, index) {
    component.on('contextmenu', function() {
    });
});
0

精彩评论

暂无评论...
验证码 换一张
取 消