我写了一个这样的 jQuery UI 小部件:
$.widget("ns.wid", {
options: {
attr1: "something1",
attr2: {
"sub_attr": this.__renderList,
"css": {
"opacity": '0.58'
},
},
},
__renderList: function() {
console.log("I should be invoked through attr2.sub_attr!");
}
});
现在它不起作用,因为this
内部attr2
没有引用小部件实例,而是引用了Window
. 如何在不直接命名的情况下引用小部件实例?谢谢。