sydcanem / bootstrap-contextmenu

Context menu plugin for Twitter's Bootstrap framework
http://sydcanem.com/bootstrap-contextmenu/
645 stars 193 forks source link

Context menu not closing if the data-toggle="context" element is removed from the dom #21

Closed brettpostin closed 11 years ago

brettpostin commented 11 years ago

The clearMenus() function relies on the presence of the originally clicked dom element in order to close the menu.

If the element is removed from the dom the .open class never gets removed and the menu remains visible.

See this jsFiddle.

As an example scenario, I'm using an AngularJS ng-repeat directive to render a number of taskbar "items". Right clicking on these taskbar items opens up the bootstrap contextmenu.

One of options within this menu is responsible for closing a module and removing the taskbar item from the dom. When this happens the context menu stays visible.

sydcanem commented 11 years ago

Hey, can you do this? When the taskbar item is removed call closemenu() function on the item before removing it to close the context menu.