Skip to content

Commit

Permalink
Fixing Issue #63 - Backdrop is not properly removed on destroy
Browse files Browse the repository at this point in the history
  • Loading branch information
rodneyrehm committed Jul 14, 2012
1 parent 8b95570 commit 93a381d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions src/jquery.contextMenu.js
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -754,7 +754,7 @@ var // currently active contextMenu trigger
// hide menu if callback doesn't stop that // hide menu if callback doesn't stop that
if (callback.call(root.$trigger, key, root) !== false) { if (callback.call(root.$trigger, key, root) !== false) {
root.$menu.trigger('contextmenu:hide'); root.$menu.trigger('contextmenu:hide');
} else { } else if (root.$menu.parent().length) {
op.update.call(root.$trigger, root); op.update.call(root.$trigger, root);
} }
}, },
Expand All @@ -764,9 +764,9 @@ var // currently active contextMenu trigger
}, },


// hide <menu> // hide <menu>
hideMenu: function(e) { hideMenu: function(e, data) {
var root = $(this).data('contextMenuRoot'); var root = $(this).data('contextMenuRoot');
op.hide.call(root.$trigger, root); op.hide.call(root.$trigger, root, data && data.force);
}, },
// focus <command> // focus <command>
focusItem: function(e) { focusItem: function(e) {
Expand Down Expand Up @@ -856,14 +856,14 @@ var // currently active contextMenu trigger
}); });
} }
}, },
hide: function(opt) { hide: function(opt, force) {
var $this = $(this); var $this = $(this);
if (!opt) { if (!opt) {
opt = $this.data('contextMenu') || {}; opt = $this.data('contextMenu') || {};
} }


// hide event // hide event
if (opt.events && opt.events.hide.call($this, opt) === false) { if (!force && opt.events && opt.events.hide.call($this, opt) === false) {
return; return;
} }


Expand Down Expand Up @@ -1297,6 +1297,11 @@ $.contextMenu = function(operation, options) {


$('#context-menu-layer, .context-menu-list').remove(); $('#context-menu-layer, .context-menu-list').remove();
} else if (namespaces[o.selector]) { } else if (namespaces[o.selector]) {
var $visibleMenu = $('.context-menu-list').filter(':visible');
if ($visibleMenu.length && $visibleMenu.data().contextMenuRoot.$trigger.is(o.selector)) {
$visibleMenu.trigger('contextmenu:hide', {force: true});
}

try { try {
if (menus[namespaces[o.selector]].$menu) { if (menus[namespaces[o.selector]].$menu) {
menus[namespaces[o.selector]].$menu.remove(); menus[namespaces[o.selector]].$menu.remove();
Expand Down

0 comments on commit 93a381d

Please sign in to comment.