jQuery アプリケーション アーキテクチャのベスト プラクティスを探しています。
このサンプルは機能していますが、これは最善の方法ではないと思います。
サンプルとして、カーネル関数 (config の読み込み、init サブモジュールなど) とタブの dub-module があります。
"use strict";
(function($, app, window) {
app.kernel = function() {
var self = this;
app.tabs().init(); // init tabs sub-module
return self;
};
app.tabs = function() {
var self = this;
self.init = function() {
console.log('tabs function init');
};
return self;
};
})(jQuery, window.SuperPuper || (window.SuperPuper = {}), window);
$(function() {
new SuperPuper.kernel();
});
以下の資料を作成しました: