diff --git a/template/app/History.js b/template/app/History.js index 8e247669d71e0638dcc28047f75f0ada2e1ada1d..83965030e1336f02349283a890ff412ac32c1cc3 100644 --- a/template/app/History.js +++ b/template/app/History.js @@ -9,11 +9,28 @@ Ext.define("Docs.History", { */ init: function() { Ext.util.History.init(function() { - this.navigate(Ext.util.History.getToken()); + this.historyLoaded = true; + this.initialNavigate(); }, this); + Ext.util.History.on("change", this.navigate, this); }, + /** + * Called from Tabs controller to notify that initial tabs loading had been done. + */ + notifyTabsLoaded: function() { + this.tabsLoaded = true; + this.initialNavigate(); + }, + + // Invoke initial navigation only after both tabs and history are loaded + initialNavigate: function() { + if (this.tabsLoaded && this.historyLoaded) { + this.navigate(Ext.util.History.getToken()); + } + }, + // Parses current URL and navigates to the page navigate: function(token) { var url = this.parseToken(token); diff --git a/template/app/controller/Tabs.js b/template/app/controller/Tabs.js index 5a27a45e151ac7693e3a6b0dc3821bcf05ab2c9c..9c0a12517f3d5700563fbe95c797b39baa3f4777 100644 --- a/template/app/controller/Tabs.js +++ b/template/app/controller/Tabs.js @@ -3,7 +3,10 @@ */ Ext.define('Docs.controller.Tabs', { extend: 'Ext.app.Controller', - requires: ['Docs.Settings'], + requires: [ + 'Docs.History', + 'Docs.Settings' + ], refs: [ { @@ -93,6 +96,7 @@ Ext.define('Docs.controller.Tabs', { this.addTabFromTree(url, {}); }, this); } + Docs.History.notifyTabsLoaded(); }, /**