Comments (6)
Hello @iwiszhou,
i'm not able to reproduce this behavior. Also i'm not sure if you call this in correct manner. Might you create an example/fiddle for me? I would like to investigate on this ...
Thanks!
from jquery.lazy.
Hi @eisbehr-
Below is the example I am running in the local. You can just download the or copy the whole html and run locally, you will see/reproduce the error.
https://gist.github.com/iwiszhou/69a4c16d6d19c8a268b4
Thanks!
from jquery.lazy.
Hello @iwiszhou,
i really don't understand what you want to archive with your script. Why do you call loadAll
? This function will load only the already registered elements left, not the new elements loaded over ajax.
The error you got when call loadAll
is because all element are already loaded (the first three). I will fix this problem, but it will not affect the functionality.
from jquery.lazy.
Version 0.5.4 will fix the error on call loadAll
and update
after all images are loaded.
I'll close this issue. Let me know if you need more help.
from jquery.lazy.
Hi @eisbehr-
Oh, I think I forget to describe what I am trying to do.
Let say, right now, I have a feature Pagination on my page. Every time, when user click the next page. It will fire an API call to fetch another 100 images' url from server. On the ajax callback, I will inject a new html content into my DOM. (for example, I will inject
<div><img data-src='http://exmaple.com/abc.jpg'></div>
into my existing div using jquery)
So, questions, how I can render the image I inject into my div/DOM?
Solution 1: should I destroy the existing 'lazy' instance and create a new one.
Solution 2: it there any ways I can reuse the existing 'lazy' instance to render the new image/html I just inject into my DOM?
Thanks
from jquery.lazy.
Hello @iwiszhou,
well, i think there are two possible ways to accomplish that, but there is no way to add more elements to an existing instance.
1.) Destroy the old instance and create a new one after every ajax load. Best way would be to remove the element class after loading so new instances would not get any already loaded elements. You can use the afterLoad
callback to do this.
2.) Create a instance for every page. Let your ajax response add an unique class to the elements like page-2
. So you can create an instance for the page: $('img.lazy.page-2').Lazy();
Hope this will help you. And only use loadAll
when you really want to load all images! ;)
from jquery.lazy.
Related Issues (20)
- In Computer works like a charm. not working on mobile devices HOT 1
- Images downloading twice in Chrome HOT 2
- How to use jQuery.Lazy() Plugin with an image containing a cache-busting hash HOT 8
- Issue when using jQuery.Lazy() Plugin with a function AJAX call HOT 5
- images aren't shown if they doesn't come to visibility by scroll HOT 2
- images with srcset load all at once HOT 2
- Slow image load handling HOT 1
- Custom Content Loaders broken with jQuery 3.x HOT 4
- Doesn't trigger when new elements are toggled in HOT 2
- JS Error When Using on Cloned Template HOT 3
- laravel-mix, cannot reuse lazy HOT 1
- Deprecated
- Defer the lazy loading HOT 1
- Don`t change src when exists HOT 4
- Intermittent image load with AJAX return
- Custom loader using Ajax fails (not even fired), while lazyloading images work. HOT 1
- Bugs with gsap scrolltrigger in Safari HOT 3
- Throttling by number of calls HOT 1
- Images loading twice HOT 2
- Not able to get it working in FireFox 121.0.1 on Mac OS
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jquery.lazy.