Giter VIP home page Giter VIP logo

Comments (9)

dkern avatar dkern commented on May 24, 2024

Hello @anshudaur !

Well, I can tell you for now that your posted code can't work. Because it is invalid JavaScript. You can't place console.log directly inside an object.

Beside this, your code has another problem: you set display to block after every load or error. This means that even elements that are not handled by now will be set to this. You should instead use the element parameter of the callback to only set this to the correct items. But it is not needed in onFinishedAll.

$(function() {
    $(".lazy").lazy({
        // console.log("inside lazy function"); <-- this line is not allowed !
        afterLoad: function(element) {
            element.css("display", "block");
            console.log("Dealer locator data is about to be loaded");
        },
        onError: function(element) {
            element.css("display", "block");
            console.log('onError of lazyLoad');
        },
        onFinishedAll: function() {
            console.log('lazy loading finished');
        }
    });
});

That are all problems I can see for now. That should work in general.

from jquery.lazy.

anshudaur avatar anshudaur commented on May 24, 2024

HI, i tried your change, but the function call is itself not happening

from jquery.lazy.

dkern avatar dkern commented on May 24, 2024

Well, then I need to see your whole code. It is impossible to tell whats wrong without seeing the problem. Please use jsfiddle to create an example reproducing the problem.

from jquery.lazy.

anshudaur avatar anshudaur commented on May 24, 2024

Hi, thanks for your time. The link for jsfiddle is : https://jsfiddle.net/oge0qs3a/1/

from jquery.lazy.

dkern avatar dkern commented on May 24, 2024

I have to ask ... What are you trying to do?
Because this is completly wrong usage. Are you familar with the principle of lazy loading?

from jquery.lazy.

anshudaur avatar anshudaur commented on May 24, 2024

Hi, Ok i will explain you what i want to do. My page is pretty big and the bottom of it, i am getting data dynamically which is making my page slow. SO i want to implement lazy loading which according to me is not loading the element untill you scroll down to the page where your element exists. That's right , right?

from jquery.lazy.

dkern avatar dkern commented on May 24, 2024

Well, basically. Lazy can load images by default (without plugins) when scrolling to them. It is even possible to load more data on scroll, like over ajax.

But it is not possible as you did. Think about it by yourself. Everything in the html document will be loaded when the browser load it. So placing your ul inside a div will not prevent the browser from loading it. You will only show the element, when the user scrolls to it.

For lazy loading content like this you have to do a bit more work. I wrote an example some time ago on stackoverflow. This should give you an idea what you have to do.

from jquery.lazy.

anshudaur avatar anshudaur commented on May 24, 2024

You are right .. I will take a look into this. Thanks.

from jquery.lazy.

anshudaur avatar anshudaur commented on May 24, 2024

Hey it worked. Thanks a ton for your patience and solution :P

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.