Skip to content

Commit b8f8bf6

Browse files
committed
Use .on() / .off() syntax
1 parent 782c200 commit b8f8bf6

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 1.16.0-1 / Unreleased
22

3-
*
3+
* Use `.on()` / `.off()` syntax
44

55
# 1.16.0 / 2017-03-30
66

jquery.ui-contextmenu.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ $.widget("moogle.contextmenu", {
9494
}
9595
// TODO: the selectstart is not supported by FF?
9696
if (supportSelectstart) {
97-
this.element.delegate(opts.delegate, "selectstart" + this.eventNamespace,
97+
this.element.on("selectstart" + this.eventNamespace, opts.delegate,
9898
function(event) {
9999
event.preventDefault();
100100
});
@@ -106,11 +106,11 @@ $.widget("moogle.contextmenu", {
106106
if (opts.taphold) {
107107
eventNames += " taphold" + this.eventNamespace;
108108
}
109-
this.element.delegate(opts.delegate, eventNames, $.proxy(this._openMenu, this));
109+
this.element.on(eventNames, opts.delegate, $.proxy(this._openMenu, this));
110110
},
111111
/** Destructor, called on $().contextmenu("destroy"). */
112112
_destroy: function() {
113-
this.element.undelegate(this.eventNamespace);
113+
this.element.off(this.eventNamespace);
114114

115115
this._createUiMenu(null);
116116

@@ -230,11 +230,11 @@ $.widget("moogle.contextmenu", {
230230
}
231231

232232
// Register global event handlers that close the dropdown-menu
233-
$(document).bind("keydown" + this.eventNamespace, function(event) {
233+
$(document).on("keydown" + this.eventNamespace, function(event) {
234234
if ( event.which === $.ui.keyCode.ESCAPE ) {
235235
self._closeMenu();
236236
}
237-
}).bind("mousedown" + this.eventNamespace + " touchstart" + this.eventNamespace,
237+
}).on("mousedown" + this.eventNamespace + " touchstart" + this.eventNamespace,
238238
function(event) {
239239
// Close menu when clicked outside menu
240240
if ( !$(event.target).closest(".ui-menu-item").length ) {
@@ -265,7 +265,7 @@ $.widget("moogle.contextmenu", {
265265
.hide(); // hide again, so we can apply nice effects
266266

267267
if ( opts.preventContextMenuForPopup ) {
268-
this.$menu.bind("contextmenu" + this.eventNamespace, function(event) {
268+
this.$menu.on("contextmenu" + this.eventNamespace, function(event) {
269269
event.preventDefault();
270270
});
271271
}
@@ -288,15 +288,15 @@ $.widget("moogle.contextmenu", {
288288

289289
// Note: we don't want to unbind the 'contextmenu' event
290290
$(document)
291-
.unbind("mousedown" + this.eventNamespace)
292-
.unbind("touchstart" + this.eventNamespace)
293-
.unbind("keydown" + this.eventNamespace);
291+
.off("mousedown" + this.eventNamespace)
292+
.off("touchstart" + this.eventNamespace)
293+
.off("keydown" + this.eventNamespace);
294294

295295
self.currentTarget = null; // issue #44 after hide animation is too late
296296
self.extraData = {};
297297
if ( this.$menu ) { // #88: widget might have been destroyed already
298298
this.$menu
299-
.unbind("contextmenu" + this.eventNamespace);
299+
.off("contextmenu" + this.eventNamespace);
300300
this._hide(this.$menu, hideOpts, function() {
301301
if ( self.previousFocus ) {
302302
self.previousFocus.focus();

0 commit comments

Comments
 (0)