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();
}
});
}
},
但是當我做一個選擇的警報_filter,我得到一個錯誤:「that.options is undefined」 與我嘗試訪問/使用的任何其他元素相同,就像該函數只能獲取內部定義的內容或傳遞的eventData一樣。
我錯過了什麼嗎? 謝謝
謝謝! 另一個「work arround」是將元素作爲eventData屬性傳遞:'this.element.bind(「keyup」,{element:this.element,list:this.container},this._filter);' – user706058