Skip to main content

Search and Top Navigation

#6749 closed bug (notabug)

Opened December 14, 2010 11:52AM UTC

Closed December 14, 2010 01:07PM UTC

Last modified December 14, 2010 02:20PM UTC

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.

Attachments (0)
Change History (5)

Changed December 14, 2010 01:07PM UTC by scottgonzalez comment:1

resolution: → invalid
status: newclosed

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

Changed December 14, 2010 01:12PM UTC by iangrainger comment:2

Replying to [comment:1 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?

Changed December 14, 2010 02:08PM UTC by scottgonzalez comment:3

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.

Changed December 14, 2010 02:16PM UTC by iangrainger comment:4

Replying to [comment:3 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.

Changed December 14, 2010 02:20PM UTC by scottgonzalez comment:5

_comment0: 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 bind a callback or use an event, but they're not the same.1292336432558762

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.