Skip to content

Commit

Permalink
A check to insure that the content that gets loaded into colorbox mat…
Browse files Browse the repository at this point in the history
…ches the correct ajax request (Fixes #368)
  • Loading branch information
Jack Moore committed Mar 10, 2013
1 parent eaf8c1b commit 678e538
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions jquery.colorbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@
publicMethod,
div = "div",
className,
requests = 0,
init;

// ****************
Expand All @@ -150,9 +151,10 @@
return $(element);
}

//Calculate window height - solves iOS Safari bug
// Get the window height using innerHeight when available to avoid an issue with iOS
// http://bugs.jquery.com/ticket/6724
function winheight() {
return window.innerHeight ? window.innerHeight:$(window).height();
return window.innerHeight ? window.innerHeight : $(window).height();
}

// Determine the next and previous members in a group.
Expand Down Expand Up @@ -830,7 +832,7 @@
};

publicMethod.load = function (launched) {
var href, setResize, prep = publicMethod.prep, $inline;
var href, setResize, prep = publicMethod.prep, $inline, request = ++requests;

active = true;

Expand Down Expand Up @@ -912,6 +914,10 @@
.one('load', function () {
var percent;

if (request !== requests) {
return;
}

if (settings.retinaImage && window.devicePixelRatio > 1) {
photo.height = photo.height / window.devicePixelRatio;
photo.width = photo.width / window.devicePixelRatio;
Expand Down Expand Up @@ -957,7 +963,9 @@
}, 1);
} else if (href) {
$loadingBay.load(href, settings.data, function (data, status) {
prep(status === 'error' ? $tag(div, 'Error').html(settings.xhrError) : $(this).contents());
if (request === requests) {
prep(status === 'error' ? $tag(div, 'Error').html(settings.xhrError) : $(this).contents());
}
});
}
};
Expand Down

0 comments on commit 678e538

Please sign in to comment.