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

.load() doesn't work. #49

Closed
wdews opened this issue Mar 17, 2015 · 5 comments
Closed

.load() doesn't work. #49

wdews opened this issue Mar 17, 2015 · 5 comments

Comments

@wdews
Copy link

wdews commented Mar 17, 2015

Looks like the code the .load() function references is faulty. "loadImage()" simply doesn't work. At all. It's also unclear whether you pass it a jQuery object or a native DOM element. I've tried both, doesn't work with either.

@dinbror
Copy link
Owner

dinbror commented Apr 4, 2015

Hey.

That sounds odd. Do you have a live example? How're you using it? Show code or it didn't happend ;)

@DanielTate
Copy link

@wdews If you read the introduction it says it's NOT a jQuery plugin, this would force me to assume an HTML element is expected.

@Eworm
Copy link

Eworm commented May 27, 2015

I have the same question. It doesn't matter if I use:

bLazy.load(document.getElementsByClassName('highlight-item-img'), true);
or
bLazy.load($('.highlight-item-img'), true);

I always get the same error message:
Uncaught TypeError: i.getAttribute is not a function

@DanielTate
Copy link

@Eworm

document.getElementsByClassName('highlight-item-img')
// [div.highlight-item-img]

returns an array even if its only one element

If you try

document.getElementsByClassName('highlight-item-img')[0]
// div.highlight-item-img

You need to pass in one element.

If you read the source you can see the function expects only ONE element.

Blazy.prototype.load = function(element, force){
    if(!isElementLoaded(element)) loadImage(element, force);
};

I would suggest that the script have a type check somewhere to prevent this error although it is very straight forward.

@dinbror
Copy link
Owner

dinbror commented Oct 30, 2015

Fixed in v. 1.5.0, now you can pass a single element, a list of elements or jquery elements

@dinbror dinbror closed this as completed Oct 30, 2015
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

4 participants