1
我無法找出項目的名稱空間。在Javascript中訪問兄弟命名空間,在SEAF中更改命名空間變量
我的命名空間看起來像這樣迄今:
var NS = NS || {};
NS.Utils = NS.Utils || {};
NS.Models = NS.Models || {};
NS.Views = NS.Views || {};
NS.App = (function() {
this.data = "hello";
var init = function() {
alert(data);
};
return {
data: this.data,
init: init,
};
}());
然後我這個初始化:
(function ($, global, data) {
$(global).click(function() {
NS.App.init();
});
NS.App.data = "hello testing";
NS.App.init();
}(jQuery, window, data));
但由於某些原因,第二,NS.App.init()調用不使用更新的NS.App.data變量。我怎樣才能解決這個問題?
另外,如何引用NS.App中的其他名稱空間?例如,如果我想在NS.App中使用NS.Utils?
爲什麼數據顯示舊文本?瘋狂... – 2012-08-17 01:05:32
是啊,不知道,我會期待'undefined' – elclanrs 2012-08-17 01:25:09