Skip to content

Commit

Permalink
Merge pull request #7687 from piwik/7404
Browse files Browse the repository at this point in the history
Prevent useless ajax requests in live widgets (fixes #7404)
  • Loading branch information
mnapoli committed Apr 16, 2015
2 parents 8fec3c3 + 17943fc commit 00209eb
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
4 changes: 2 additions & 2 deletions plugins/Live/javascripts/live.js
Expand Up @@ -82,7 +82,7 @@

if (that.isStarted) {
window.clearTimeout(that.updateInterval);
if ($(that.element).closest('body').length) {
if (that.element.length && $.contains(document, that.element[0])) {
that.updateInterval = window.setTimeout(function() { that._update() }, that.currentInterval);
}
}
Expand Down Expand Up @@ -211,7 +211,7 @@
$(function() {
var refreshWidget = function (element, refreshAfterXSecs) {
// if the widget has been removed from the DOM, abort
if ($(element).parent().length == 0) {
if (!element.length || !$.contains(document, element[0])) {
return;
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/UserCountryMap/javascripts/realtime-map.js
Expand Up @@ -359,7 +359,7 @@
*/
function gotNewReport(report) {
// if the map has been destroyed, do nothing
if (!self.map) {
if (!self.map || !self.$element.length || !$.contains(document, self.$element[0])) {
return;
}

Expand Down

0 comments on commit 00209eb

Please sign in to comment.