Topic: MifMenu - "detach" method?
Is it possible to detach menu from DIV element that was attached to it using menu.attachTo(div) ?
thanks
You are not logged in. Please login or register.
Pages 1
Is it possible to detach menu from DIV element that was attached to it using menu.attachTo(div) ?
thanks
hey moro
actually, I ran into quite a problem with MifMenu. maybe you could help me out.
I am working on images data grid that is similar to Windows Explorer's Thumbnails view. MifMenu is attached to every tile/square.
I need to be able to dynamically reconfigure menu items depending on number of tiles selected: if more than one tiles are hilighted - I want to have "Delete all selected" item in addition to "Delete" that is always there.
Here's my code:
var itemMenu = {items:[]};
itemMenu.items.push({
name: 'Delete',
onAction: function()
{
this.menu.el.fireEvent('deleteOne')
}
});
if (this.options.selected.length > 1)
{
itemMenu.items.push({
name: 'Delete all selected',
onAction: function()
{
this.menu.el.fireEvent('deleteAll')
}
});
}
var menu = new Mif.Menu(
{
list: itemMenu
},
{
container: Mif.Menu.Container,
options:{
...
}
});
menu.attachTo(tile);
So menu is initialized with each click on a tile - this is done to reconfigure it and show "Delete all selected" item.
The problem is that menu.attach() method does not replace existing attached menu with the new one. As a result I have TWO overlapping menus.
Questions:
1. Is it possible to detach an existing menu from a tile?
2. Can menu.attach() method override menu that's been attached previously?
My preferred solution would be if you could add a new method that accepts new 'list' definition that contains new/updated items for the existing & attached menu.
This would enable me to write something like:
var menu = new Mif.Menu(
{
list: OriginalMenuItems
},
{
container: Mif.Menu.Container,
options:{
...
}
});
menu.attachTo(tile);
and later on trigger display using:
menu.display({list: UpdatedMenuItems})
What do you think?
Thanks
need some time to create this functionality, mb next week
Posts [ 3 ]
Pages 1
Powered by PunBB