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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:04:56+00:00 2026-05-20T18:04:56+00:00

I’m super new to programming, I currently have a table of venues which can

  • 0

I’m super new to programming, I currently have a table of venues which can be filtered by type and/or area using a form with checkboxes on the index page.

With the help of railscasts I have added the ability to add a review to a venue using AJAX. How can I go about AJAXifying my filter form?

So far I have this:

venues controller

def index
  if
    @venues = Venue.with_type(params[:venuetypes]).with_area(params[:areas])
  else
    @venues = Venue.all
  end
end

venues index

<div class="filter_options_container">
  <%= form_tag '', :method => :get, :id => 'filter_venues' do %>

    <fieldset class="filter_form_fieldset venuetypes">
      <% Venuetype.all.each do |v| %>
        <%= check_box_tag 'venuetypes[]', v.id, false, :id => "venuetype-#{v.id}" %>
        <label for="venuetype-<%= v.id %>"><%= v.name %></label>
      <% end %>
    </fieldset>

    <fieldset class="filter_form_fieldset areas">
      <% Area.all.each do |a| %>
        <%= check_box_tag 'areas[]', a.id, false, :id => "area-#{a.id}" %>
        <label for="area-<%= a.id %>"><p1><%= a.name %></p1></label>
      <% end %>
    </fieldset>

    <div class="filter_form_button">
      <p2><input type="submit" value="Filter"/></p2>
    </div>
  <% end %>
</div>

I’ve tried to apply the same method used in the jQuery railscast for adding a review using AJAX but theres too many peices which dont fit and think I’m heading down the wrong path with this, can anyone give me any pointers?

Thanks very much for any help.

  • 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-20T18:04:57+00:00Added an answer on May 20, 2026 at 6:04 pm

    For the HTML/JS side, I’d recommend using the jQuery Form Plugin – there are many options, but in your case it might be as simple as:

    $('#filter_venues').ajaxForm({
        success: function() {/* ...load the response... */}
    });
    

    For the Rails side, I’d do the following (I do this in my app, so I can guarantee it’s a valid setup):

    Split your index page into a template and a partial, like so:

    index.html.erb:

    <!-- ...filter form, some other stuff... -->
    <table>
        <thead>
            <!-- all the attributes you feel like showing -->
        </thead>
    <%= render :partial => 'index.ajax' -%>
    </table>
    <!-- more other stuff... -->
    

    _index.ajax.erb:

    <tbody id="venue-tbody">
    <% @venues.each do |venue| -%>
        <tr>
            <!-- all the attributes you have headers for -->
        <tr>
    <% end -%>
    </tbody>
    

    Then, change your index action so that it renders either the full page (for a /venues.html request), or only the partial (for a /venues.ajax request):

    respond_to do |format|
        format.html {render :template => 'venues/index.html'}
        format.ajax {render :template => 'venues/_index.ajax', :layout => false}
    end
    

    I needed to register my own dummy MIME type to get this to work (in config/environment.rb):

    #Make a fake MIME type for AJAX calls:
    Mime::Type.register 'application/x-ajax', :ajax
    

    A more detailed JS example for this setup would look like so (I think this should be fully functional. I think.):

    function load_new_venues(data, status, request)
    {
        $('#venue-tbody').replaceWith(data);
        //Any event handlers that need to be set for the new HTML elements...
    }
    
    $('#filter_venues').ajaxForm({
        dataType: 'html',
        success: load_new_venues,
        url: '/venues.ajax'
    });
    

    Hope this helps – and sorry if it turned into a small novel… Cheers!

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

Sidebar

Related Questions

I have a text area in my form which accepts all possible characters from
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I have an autohotkey script which looks up a word in a bilingual dictionary
I have an array which has BIG numbers and small numbers in it. I
I have thousands of HTML files to process using Groovy/Java and I need to
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has

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.