Browse Source

AMBARI-6204. Selected main menu option is not highlighted first time. (akovalenko)

Aleksandr Kovalenko 11 years ago
parent
commit
891b1205d3
1 changed files with 13 additions and 12 deletions
  1. 13 12
      ambari-web/app/views/main/menu.js

+ 13 - 12
ambari-web/app/views/main/menu.js

@@ -71,25 +71,26 @@ App.MainMenuView = Em.CollectionView.extend({
      *    Adds observer on lastSetURL and calls navigation sync procedure
      *    Adds observer on lastSetURL and calls navigation sync procedure
      */
      */
   didInsertElement:function () {
   didInsertElement:function () {
-    App.router.location.addObserver('lastSetURL', this, 'renderOnRoute');
     this.renderOnRoute();
     this.renderOnRoute();
   },
   },
 
 
   /**
   /**
    *    Syncs navigation menu with requested URL
    *    Syncs navigation menu with requested URL
    */
    */
-  renderOnRoute:function () {
-    var last_url = App.router.location.lastSetURL || location.href.replace(/^[^#]*#/, '');
-    if (last_url.substr(1, 4) !== 'main' || !this._childViews) {
-      return;
+  renderOnRoute: function () {
+    if (App.router.get('clusterController.isLoaded')) {
+      var last_url = App.router.location.lastSetURL || location.href.replace(/^[^#]*#/, '');
+      if (last_url.substr(1, 4) !== 'main' || !this._childViews) {
+        return;
+      }
+      var reg = /^\/main\/([a-z]+)/g;
+      var sub_url = reg.exec(last_url);
+      var chunk = (null != sub_url) ? sub_url[1] : 'dashboard';
+      $.each(this._childViews, function () {
+        this.set('active', this.get('content.routing') == chunk ? "active" : "");
+      });
     }
     }
-    var reg = /^\/main\/([a-z]+)/g;
-    var sub_url = reg.exec(last_url);
-    var chunk = (null != sub_url) ? sub_url[1] : 'dashboard';
-    $.each(this._childViews, function () {
-      this.set('active', this.get('content.routing') == chunk ? "active" : "");
-    });
-  },
+  }.observes('App.router.location.lastSetURL', 'App.router.clusterController.isLoaded'),
 
 
   itemViewClass:Em.View.extend({
   itemViewClass:Em.View.extend({