Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Upon troubleshooting, it was found that when an image throws an error, this inside the callback refers to the image element and not the JustifiedGallery instance. This causes a TypeError because this.resetImgSrc is not a function in the context of the image element.

To resolve this, I ensured that this correctly refers to the JustifiedGallery instance by using .bind(this) on the callback function.
  • Loading branch information
saas786 committed Jun 3, 2024
1 parent c8ef4d2 commit 73fb2fc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/js/justifiedGallery.js
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ JustifiedGallery.prototype.displayEntry = function ($entry, x, y, imgWidth, imgH

$image.one('error', function () {
this.resetImgSrc($image); //revert to the original thumbnail
});
}.bind(this));

var loadNewImage = function () {
// if (imageSrc !== newImageSrc) {
Expand Down

0 comments on commit 73fb2fc

Please sign in to comment.