diff --git a/public/js/icinga/events.js b/public/js/icinga/events.js index d458ab7fc..cc927feb6 100644 --- a/public/js/icinga/events.js +++ b/public/js/icinga/events.js @@ -100,7 +100,7 @@ // Destroy Icinga, clean up and interrupt pending requests on unload $( window ).on('unload', { self: this }, this.onUnload); - $( window ).on('beforeunload', { self: this }, this.onBeforeUnload); + $( window ).on('beforeunload', { self: this }, this.onUnload); // We catch scroll events in our containers $('.container').on('scroll', { self: this }, this.icinga.events.onContainerScroll); @@ -153,15 +153,6 @@ icinga.destroy(); }, - onBeforeUnload: function (event) { - var icinga = event.data.self.icinga; - - // Browsers may call the error handler on all pending AJAX requests, when the page is reloaded, - // which could in turn cause needless error messages to show up in the frontend until the page is loaded. - // To circumvent this cancel all pending requests. - icinga.loader.cancelRequests(); - }, - /** * A scroll event happened in one of our containers */ @@ -569,7 +560,7 @@ $(window).off('resize', this.onWindowResize); $(window).off('load', this.onLoad); $(window).off('unload', this.onUnload); - $(window).off('beforeunload', this.onBeforeUnload); + $(window).off('beforeunload', this.onUnload); $(document).off('scroll', '.container', this.onContainerScroll); $(document).off('click', 'a', this.linkClicked); $(document).off('click', 'table.action tr[href]', this.rowSelected); diff --git a/public/js/icinga/loader.js b/public/js/icinga/loader.js index e01e03cec..99667ac1c 100644 --- a/public/js/icinga/loader.js +++ b/public/js/icinga/loader.js @@ -793,22 +793,16 @@ }, /** - * Cancel and dereference all pending requests and dereference this object + * On shutdown we kill all pending requests */ destroy: function() { - this.icinga.loader.cancelRequests(); - this.icinga = null; - this.requests = {}; - }, - - /** - * Cancel all pendings ajax requests - */ - cancelRequests: function() { $.each(this.requests, function(id, request) { request.abort(); }); + this.icinga = null; + this.requests = {}; } + }; }(Icinga, jQuery));