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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:50:35+00:00 2026-05-27T04:50:35+00:00

I have a partial which returns results from the Amazon-ecs API (searches for books).

  • 0

I have a partial which returns results from the Amazon-ecs API (searches for books). It takes about 2.5 seconds to return values, so I want to add a spinner (and ideally hide the search button) but I’ve had a tough time getting it to work.

I already have javascript refreshing the partial with the results. I’d just like the button to give me a spinner (and hide the search button) until the partial finishes reloading.

Here is my main view (index.html.erb) which renders a partial of search results, each of which is added temporarily as an object in AmazonItems:

<%= form_tag amazon_items_path, :method => :get, :remote => true do %>
  <p>
  <%= text_field_tag :query, params[:query] %>

  <span id="spinner" style="display:none">
    <%= image_tag 'ajax-loader.gif' %>
  </span>

  <span id="search_button">
    <%= submit_tag "Search" %>
  </span>

  </p>
<% end %>

<h1>Searching Amazon</h1>

<div id="amazon_returned">
  <%= render 'amazon_returned' %>
</div>

My only JS code is in the update.js.erb file, which looks like:

$("#amazon_returned").html("<%=j render 'amazon_returned' %>");

I’m sure this is easy, but I can’t get it work. Thanks!

EDIT: my partial “_amazon_returned.html.erb” looks like

<table>
<% for amazon_item in @amazon_items %>
  <td> amazon_item.title </td>
  ...ETC...
<% end %>
</table>
  • 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-27T04:50:35+00:00Added an answer on May 27, 2026 at 4:50 am

    You can hook into the before event to do this:

    $(function() {
      $("form").on("ajax:before", function() {
        $("#spinner, #search_button").toggle();
      });
    });
    

    Then, in your update.js.erb, add this again to toggle them back:

    $("#spinner, #search_button").toggle();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a view page with ajax.action link which returns a partial view from
I have the following plugin, which takes a partial game name, bounces it off
I have a C++ project in which I have to return some variables from
I noticed the docs have: <%= item_counter %> But I have a partial which
I currently have a page which is declared as follows: public partial class MyPage
I have a page which contains a html.RenderPartial, that renders an ASP.NET MVC partial
I have this partial code: if ($getRecords = $con->prepare(SELECT * FROM AUCTIONS WHERE ARTICLE_NO
I have a HTML table which I add items to from javascript on an
I have this code for validation of the Customer class which is created from
I have an ajax action link which is appending a partial to a div.

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.