Giter VIP home page Giter VIP logo

Comments (6)

dkern avatar dkern commented on June 4, 2024

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.

iwiszhou avatar iwiszhou commented on June 4, 2024

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.

dkern avatar dkern commented on June 4, 2024

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.

dkern avatar dkern commented on June 4, 2024

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.

iwiszhou avatar iwiszhou commented on June 4, 2024

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.

dkern avatar dkern commented on June 4, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.