アプリケーション コードの外部からデータをロードする場合は、次のように実行できます。
ドキュメントにプリロード関数を追加します (すべての app.js および store.js の下):
<script>
window.preload = function(store) {
store.loadMany(App.Post,[10,11],[{ id: 10, content: "testcontent", author_id: 1 },{ id: 11, content: "testcontent2", author_id: 1 }]);
store.load(App.User,{ id: 1, username: "supervisor"});
}
</script>
ApplicationRouteでは、ストアをパラメータとしてプリロード関数を呼び出します。
App.ApplicationRoute = Ember.Route.extend({
setupController: function(controller, model) {
window.preload(this.store);
}
});
このようにして、アプリケーションの初期化時に行われる要求の量を減らします。