0
私は要素にハンドラをバインドした少しのjQuery UIウィジェットを作成しています:JQuery UI:ハンドラをメソッドにバインドする:要素を取得できませんか?
this.element.bind("keyup", { list: this.container }, this._filter);
ウィジェットはオプションがあります。
options:
{
dataUrl: '',
isEnabled: true
},
_filter: function (event)
{
var input = $(this);
var that = this;
alert(that.options.isEnabled);
if (that.options.enabled) {
that.container.show();
event.data.list.find("li").each(function() {
if ($(this).text().toLowerCase().indexOf(input.val().toLowerCase()) < 0) {
$(this).hide();
}
else {
$(this).show();
}
});
}
},
しかし、ときに私は1つのオプションの警告を行います_filter、私はエラーが発生します: "that.optionsは未定義です" 私がアクセスしようとする他の要素と同じです。関数が内部で定義されているものか、渡されたeventDataからのみ取得できるかのようです。
何か不足していますか? ありがとう
ありがとうございます! "work arround"は、この要素をeventDataプロパティとして渡すことです: 'this.element.bind(" keyup "、{element:this.element、list:this.container}、this._filter);' – user706058