Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: this.resetImgSrc is not a function #389

Open
saas786 opened this issue Jun 3, 2024 · 0 comments
Open

Uncaught TypeError: this.resetImgSrc is not a function #389

saas786 opened this issue Jun 3, 2024 · 0 comments

Comments

@saas786
Copy link

saas786 commented Jun 3, 2024

I am experiencing an issue with JustifiedGallery. When I attempt to destroy the gallery, it throws the following error:

$('#commandtest').justifiedGallery('destroy');
jquery.justifiedGallery.js:222 Uncaught TypeError: this.resetImgSrc is not a function
    at HTMLImageElement.<anonymous> (jquery.justifiedGallery.js:222:17)
    at HTMLImageElement.i (jquery.min.js?ver=3.7.1:2:37034)
    at HTMLImageElement.dispatch (jquery.min.js?ver=3.7.1:2:40035)
    at v.handle (jquery.min.js?ver=3.7.1:2:38006)
saas786 added a commit to saas786/Justified-Gallery that referenced this issue Jun 3, 2024
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant