Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6929297
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:17:56+00:00 2026-05-27T11:17:56+00:00

I was searching Google and found some code that implements a jQuery lazy load

  • 0

I was searching Google and found some code that implements a jQuery lazy load plug-in for gridviews, but I’m confused how it works.

Here’s the markup:

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript" charset="utf-8"></script>

<script src="http://www.appelsiini.net/projects/lazyload/jquery.lazyload.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
  $(function() {
    $("table[id*=GridView1] img").lazyload({
          placeholder: "http://www.gallery2c.com/admin/Upload/ThumbNail/customers%20own%20image.jpg",
          event: "sporty"
      });
  });
  $(window).bind('load', function() {
      var timeout = setTimeout(function() { $("img").trigger("sporty") }, 5000);
  });      
 </script>
</head>
<body>
<form id="form1" runat="server">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false" class="tablesorter">
    <Columns>
        <asp:TemplateField HeaderText="ImageID">
            <ItemTemplate>
                <%#Eval("ImageID")%>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Image">
            <ItemTemplate>
                <img  src='<%#Eval("Thumb")%>' />
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>
</form>
</body>
</html>

And here’s the server-side code:

protected void Page_Load(object sender, EventArgs e)
{
    var imageDataSource = (new[] { new { ImageID = 0, URL = "http://www.gallery2c.com/admin/Upload/FullImage/moda01.jpg", 
                                Thumb = "http://www.gallery2c.com/admin/Upload/ThumbNail/moda01.jpg" } }).ToList();
    for (int i = 1; i < 10; i++)
    {
        imageDataSource.Add(new
        {
            ImageID = 0,
            URL = "http://www.gallery2c.com/admin/Upload/FullImage/moda0" + i.ToString() + ".jpg",
            Thumb = "http://www.gallery2c.com/admin/Upload/ThumbNail/moda0" + i.ToString() + ".jpg"
        });
    }
    GridView1.DataSource = imageDataSource;
    GridView1.DataBind();
}

After reading this code I understand that when the page loads the gridview is data bound in the serverside code. When the client side onload event is fired, the ‘sporty’ event is setup to call repeatedly every 5 seconds. Why should the ‘sporty’ event be called every 5 seconds?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T11:17:57+00:00Added an answer on May 27, 2026 at 11:17 am

    The setTimeout function in your example will wait 5 seconds and then raise the sporty event. It won’t raise it every 5 seconds however. See the setTimeout documentation for more info. The link also mentions how infinite loops are implemented.

    In you code example, the gridview would be rendered on the page 5 seconds the page was ready rendering.

    The jQuery lazyload plugin is for rendering html at a later moment in time (i.e. not when the browser is rendering the rest of the page). This way, you can load images that are at the bottom of your page only when the user scrolls down. If the user doesn’t scroll down, they will not be rendered, speeding up the load time of your page.
    You can also let the plugin load the images when certain events are raised. These events can be a click on a button, but in javascript you can define events as you please. So you can define a ‘sporty’ event, but also a ‘foobar’, ‘something’,… event.

    Finally, the lazyload plugin isn’t limited to images. So you can also work with gridviews (which render as tables).

    So, to answer your question:

    • the sporty event is only raised once, and 5 seconds after the page was finished loading
    • the lazyload plugin will render the gridview when the sporty event is raised
    • so, the gridview will become visible after 5 seconds

    Update

    The lazyload plugin is meant for images, but, as a good jQuery plugin, can work with other elements. For images, it forces the browser not to load the image until the user can see the image (i.e. by scrolling down), or until a certain event is raised. For other elements, the lazyload plugin doesn’t really make a lot of sense.

    If you want to lazyload a table with data, you’re going to have to set it up yourself. A possible solution could be to use jQuery to make an AJAX call to your server and request the data. Then put that data into your table. You could make this AJAX call a delayed call with the setTimeout function you mentioned in your question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I was looking at some jQuery UI code, a found a weird behavior there:
I've found the shipping gem for ruby here http://shipping.rubyforge.org/ searching on google for some
I've written some very simple code (a Google Chrome extension) that gets the keywords
I was searching Google for a page offering some simple OpenMp algorithms. Probably there
Searching on Google reveals x2 code snippets. The first result is to this code
Where does one go to report bugs in Google Code? Alas, searching for Google
I thought this was asked before, but 15 minutes of searching on Google and
I have been searching around using Google but I can't find an answer to
It is known that google has best searching & indexing algorithm. The also have
I really wish that Google was better at searching for syntax: decades :: (RealFrac

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.