#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.
Workaround (as shown above) is to separately bind to the event, then unbind works.
Change History (5)
comment:1 follow-up: 2 Changed 12 years ago by
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 Changed 12 years ago by
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 follow-up: 4 Changed 12 years ago by
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 Changed 12 years ago by
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 12 years ago by
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.
Callbacks are not bound as event handlers. Change the option to null if you want to remove the callback.