Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#6749 closed bug (notabug)

Unable to unbind event handlers set as options

Reported by: iangrainger Owned by:
Priority: minor Milestone: 1.9.0
Component: ui.autocomplete Version: 1.8.7
Keywords: Cc:
Blocked by: Blocking:

Description

I cannot call unbind for events whose handlers I added as options when creating an autocomplete widget. May be the same for other widgets, I've not tested.

Reproduction

Workaround (as shown above) is to separately bind to the event, then unbind works.

Change History (5)

comment:1 Changed 9 years ago by Scott González

Resolution: invalid
Status: newclosed

Callbacks are not bound as event handlers. Change the option to null if you want to remove the callback.

comment:2 in reply to:  1 Changed 9 years ago by iangrainger

Replying to scott.gonzalez:

Callbacks are not bound as event handlers. Change the option to null if you want to remove the callback.

Ah, I see. Apologies.

I assume I missed this note in the documentation, then? Or is it too obvious?

comment:3 Changed 9 years ago by Scott González

I'm sure we don't document it on every option, but there's nothing saying that the options actually bind an event that you can later unbind.

comment:4 in reply to:  3 Changed 9 years ago by iangrainger

Replying to scott.gonzalez:

I'm sure we don't document it on every option, but there's nothing saying that the options actually bind an event that you can later unbind.

That's true - I don't want to be a pain, but it _could_ be confusing that its possible to modify behaviour in two different ways, by binding to events and by passing in callback functions.

Might it be worth a short note on the bind/unbind API reference noting that callbacks cannot be unbound, so others won't have the same confusion?

I'll go make a comment on unbind() to that effect.

comment:5 Changed 9 years ago by Scott González

This has nothing to do with the way .unbind() is implemented and .unbind() shouldn't include information specific to jQuery UI. This is very similar to how the Ajax events work: you can provide a callback or bind an event, but they're not the same.

Last edited 9 years ago by Scott González (previous) (diff)
Note: See TracTickets for help on using tickets.