Open isaacalves opened 9 years ago
Yup same error for me:
"Uncaught Element is not an <img> but does not have a background-image"
In my case the script breaks. I assume it's some kind of conflict with other scripts on the site as it works on the blog section. I'll report back if I track the conflict down.
I had the same issue. It is because the script throws an error if it doesn't find the elements. However in my case I just don't care if it doesn't find anything, I don't want that all my scripts suddenly stop working because of this. I adjusted line 167 and 189 to not throw an error. (just commented the lines with 'throw' out). Perhaps it should only inform the user when debug is enabled? Are there any side effects in removing the throw declarations?
Since it is quite impossible to always have all elements in all pages of a website, the script should definitely not throw "Uncaught" errors. Just quietly ignore the "not found" elements seems better.
I got around this by checking for the class name that triggers the script before initializing it on a page. Definitely agree that it should just fail gracefully if nothing is found.
if( $('.bgcheck')[0] ) {
BackgroundCheck.init({
targets: '#back-to-top',
images: '.bgcheck',
threshold: 70
});
}
I had the same problem and could only fix it by adding the background-image property inlined instead of declaring it in my stylesheet
I've got the following message:
Uncaught Element is not an but does not have a background-image
That doesn't necessarily had to make the script break, because there were other elements on the page with that class for background-check to check.