【发布时间】:2013-06-16 06:15:50
【问题描述】:
我创建了一个 Javascript 命名空间以避免与其他 Javascript 代码冲突。
var ns = {
init: function() {
$('a').click(this.clickHandler);
},
clickHandler: function() {
// Some code here ..
// The keyword "this" does not reference my "ns" object anymore.
// Now, it represents the "anchor"
this.updateUI();
},
updateUI: function() {
// Some code here ...
}
};
请问,如何引用我的封闭命名空间?
【问题讨论】:
标签: javascript jquery this javascript-namespaces