Skip to content

Commit

Permalink
JS: Use _this when saving a reference to this in Navigation::onRender…
Browse files Browse the repository at this point in the history
…ed()

There a tons of places where we use self instead of _this. self is a global variable in modern browsers.

refs #5543
  • Loading branch information
lippserd committed Nov 9, 2015
1 parent 802cba3 commit bb432fc
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions public/js/icinga/behavior/navigation.js
Expand Up @@ -47,25 +47,27 @@
* @param evt {Object} The event context
*/
Navigation.prototype.onRendered = function(evt) {
var self = evt.data.self;
var _this = evt.data.self;

this.element = evt.target;

if (! self.active) {
if (! _this.active) {
// There is no stored menu item, therefore it is assumed that this is the first rendering
// of the navigation after the page has been opened.

// initialise the menu selected by the backend as active.
var $menus = $('#menu li.active', evt.target);
if ($menus.size()) {
$menus.each(function () {
self.setActive($(this));
_this.setActive($(this));
});
} else {
// if no item is marked as active, try to select the menu from the current URL
self.setActiveByUrl($('#col1').data('icingaUrl'));
_this.setActiveByUrl($('#col1').data('icingaUrl'));
}
}
self.refresh();

_this.refresh();
};

/**
Expand Down

0 comments on commit bb432fc

Please sign in to comment.