#8658 closed feature (fixed)
Widget: this._on delegates using instance.widget() instead of passed element
Reported by: | shuoink | Owned by: | |
---|---|---|---|
Priority: | minor | Milestone: | 1.9.1 |
Component: | ui.widget | Version: | 1.9.0 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
I have a somewhat complex widget that has multiple drop-down menus that are placed directly under the body tag. I expected to be able to do the following:
this._on(this._menu, {'click button': '_menu_button_click'});
... but this doesn't work and actually causes a good bit of chaos. Every button element in the entire widget (except the desired one) is now bound to _menu_button_click
. This happens because in $.Widget.prototype._on
, it only uses the passed element if there's no selector specified. Here's that code:
if ( selector ) { instance.widget().delegate( selector, eventName, handlerProxy ); } else { element.bind( eventName, handlerProxy ); }
It seems to be that it should be calling element.delegate
, not instance.widget().delegate
.
Am I doing something wrong?
Change History (5)
comment:1 Changed 11 years ago by
Type: | bug → feature |
---|
comment:2 Changed 11 years ago by
Status: | new → open |
---|---|
Summary: | this._on delegates using instance.widget() instead of passed element → Widget: this._on delegates using instance.widget() instead of passed element |
comment:4 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | open → closed |
Widget: Fix _on to use element argument for delegated events. Fixes #8658 - Widget: this._on delegates using instance.widget() instead of passed element
Changeset: 721a4b4ae027b140ca280bbc8fb8ed334081b184
comment:5 Changed 11 years ago by
Milestone: | 1.10.0 → 1.9.1 |
---|
We can probably handle this by checking if an element was passed and if so using that.