PDA

View Full Version : Set Menu to Element (<A> element)



roee
16 Jan 2010, 1:32 PM
Hi,
I created a menu and want to apply it to Element in the page (in a way that when someone triggers event on the element, the menu will be shown right next to it).

Anyone tried to do it?

Thanks,
Roee

roee
16 Jan 2010, 2:34 PM
Hi, found the solution myself..
It goes:



var menu = new Ext.menu.Menu(...);
var element = Ext.get('elementName');

menu.mon(element , 'mouseover', function() {
menu.show(element);
});


(can also simply be:


element.on('mouseover', function() {


menu.show(element);
}


but in some cases you want the event listener to be removed when the menu is not available.