Skip to content

Commit 47118d8

Browse files
committed
Fix exception when target element is deleted in select event
Close mar10#88
1 parent 0ece4f8 commit 47118d8

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
* [CHANGE] #82 Add "jquery-ui/menu" as AMD dependency
44
* [FEATURE] #85 Allow custom classes per entry
5+
* [BUGFIX] #88 Exception when target element is deleted in select event
56

67
# 1.8.1 / 2014-12-21
78

jquery.ui-contextmenu.js

+9-5
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,17 @@ $.widget("moogle.contextmenu", {
275275
.unbind("mousedown" + this.eventNamespace)
276276
.unbind("touchstart" + this.eventNamespace)
277277
.unbind("keydown" + this.eventNamespace);
278-
this.$menu
279-
.unbind("contextmenu" + this.eventNamespace);
278+
280279
self.currentTarget = null; // issue #44 after hide animation is too late
281-
282-
this._hide(this.$menu, hideOpts, function() {
280+
if( this.$menu ) { // #88: widget might have been destroyed already
281+
this.$menu
282+
.unbind("contextmenu" + this.eventNamespace);
283+
this._hide(this.$menu, hideOpts, function() {
284+
self._trigger("close");
285+
});
286+
} else {
283287
self._trigger("close");
284-
});
288+
}
285289
},
286290
/** Handle $().contextmenu("option", key, value) calls. */
287291
_setOption: function(key, value) {

0 commit comments

Comments
 (0)