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 6587247
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T16:53:36+00:00 2026-05-25T16:53:36+00:00

I am new to jquery/ajax stuff and I have really hard time trying to

  • 0

I am new to jquery/ajax stuff and I have really hard time trying to understand the concepts and how to integrate it into a rails 3 application. I saw some screencasts but I can’t figure how I can make what I want.

What I am trying to achieve is to load in a “gallery” div (in galleries/show.html.erb) several images. I am using Amazon S3 and it takes a bit of time to load these images fully. So I thought adding a spinner while images’re loading in the background could be nicer.

Here is my code sor far:

galleries/show.html.erb

<div class="main">
  <div id="ajax-status"></div>
  <div id="gallery"><%= render @gallery.photos %></div>
</div>

photos/_photo.html.erb

<section class="image">
  <%= image_tag photo.image_url %>
</section>

My first idea is to render a js partial (galleries/_show.js.erb) through ajax where while images are loaded it displays a spinner then when there are fully loaded it displays the gallery.

I would be pleased to know if it’s the right way to do it

Thanks a lot for your help and your guidelines.

  • 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-25T16:53:37+00:00Added an answer on May 25, 2026 at 4:53 pm

    Ajax won’t have the effect that you want. However, it is easier to use a pure css and jquery solution.

    First, change your HTML structure:

    galleries/show.html.erb (I use class names in case you want to have multiple galleries on a page).

    <div class="main">     
      <div class="gallery">
          <%= render @gallery.photos %>
      </div>
    </div>
    

    photos/_photo.html.erb (spinner for each image)

    <div class="image_frame">
      <%= image_tag "images/loading-spinner.gif", :class => "spinner" %>   
      <%= image_tag photo.image_url, :class => "gallery_photo" %>
    </div>
    

    Next the css…

    .gallery .image_frame img.gallery_photo {
      display: none;
    }
    

    Now the js in application.js

    $(function() {
      $('.gallery .image_frame img.gallery_photo').load(function() {
        $(this).show().siblings('.spinner').hide();
      });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have application that brings response via Ajax and creates 5-20 new jQuery click
I'm really new at this jquery stuff. I have a wcf web service running
For starters, I'm new to ASP.NET Ajax stuff, and only getting back into JQuery
I'm currently new into client-side programming, especially using the Jquery Ajax method to call
I have a jquery block that does some ajax stuff like this: $.ajax({ url:
I'm trying to learn JQuery - and I have a small problem with ajax.
Hey all I'm extremely new to jquery and ajax and I'm looking for some
I am familier with jQuery,Ajax and JSP Servlets but new to Struts2.I want to
I am writing an ajax script in jQuery. The script gets new or previous
I've been trying to use the new jquery-ui, and all but the resizable function

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.