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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:37:45+00:00 2026-06-04T20:37:45+00:00

In a Rails index view I’m implementing ajax pagination, more or less following this

  • 0

In a Rails index view I’m implementing ajax pagination, more or less following this Railscast.

When a user clicks a pagination link, I want the following steps to occur:

  1. Existing index fades out.
  2. Spinner is displayed.
  3. New index content fades in.

In index.js.erb I have the following content:

$(".ajaxable-content").fadeOut('fast');
$(".ajaxable-content").html('<div class="ajax-spinner></div>');
$(".ajaxable-content").delay(400);
$(".ajaxable-content").html('<%= escape_javascript(render :partial => "my/ajax/content" %>');
$(".ajaxable-content").fadeIn('slow');

Despite the delay function, what I’m seeing is:

  1. New content is rendered.
  2. Content fades out.
  3. Content fades in.

This is not a very good user experience!

(in addition, the spinner doesn’t seem to be displayed. Or perhaps is being replaced too quickly to be noticeable).

What is the correct way to ensure the fade out completes before the new content is rendered?

What is the best way to set this up so that the request to the database is happening in the background whilst the fading and spinner are happening?

  • 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-06-04T20:37:47+00:00Added an answer on June 4, 2026 at 8:37 pm

    Any actions in index.js.erb will be performed when its contnent is already rendered and delivered to client side. So it can be resposible only for dispaying content (and hiding “loading” spinner).
    Try to fadeOut current page and show the spinner before you send ajax request, something like (I’m using code from the screencast)

    $(function () {
      $('#products th a').live('click', function () {
        var href = this.href;
        $(".ajaxable-content").fadeOut('fast', function(){
          $(".ajaxable-content").html('<div class="ajax-spinner></div>');
          $.getScript(href);
        });
        return false;
      });
    })
    

    And in index.js.erb left only last two lines

    $(".ajaxable-content").html('<%= escape_javascript(render :partial => "my/ajax/content" %>');
    $(".ajaxable-content").fadeIn('slow');
    

    The spinner visibility also depend on you css: its parent div is hidden (faded out) when you show it.

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

Sidebar

Related Questions

In my rails view(index.html.erb), i have following structure <div> <%= render :partial => create
I'm using Rails 3 and Devise 2.0 In the index view of the Posts
I currently have the following controller method in a Rails app: def index @entries
I did rails generate controller home index But it adds this line to my
I have the following HTML dropdown box on the index view of the Search
This is a Rails 3 project using jQuery 1.4.4. I have an index action
I'm new with backbone and Rails. When I return to the index view in
My destroy link is not working. My index view: <div id=konkurrancer><%= render 'konkurrencer', :remote
I have a index view in a Rails 3 project where several line items
In a Rails 3.2 index view I am rendering two partials. <%= render :partial

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.