0

I am working on a search function on RoR that basically just has a cool visual effect when a user clicks the search button.

Here is the code in my view for search.rhtml

  <html>
  <head>
    <title>Tutor</title>
    <%= javascript_include_tag :defaults %>
  </head>
  <body>
    <h1></h1>
        <%= form_remote_tag :url =>{ :action => :search_results }, :update => "results"  %>


                    <fieldset>
                        <legend>Tutor Search.</legend>
                        <label for="searchItField">Keyword Search.</label>

                        <input class="tfield" type="text" value="FIND YOUR TUTOR HERE" name="searchItField" id="searchItField" />
                        <span id="Submit_search">

                            <span id="Submit_search_hover"><input type="submit" id="Submit" value="Search" /></span>

                        </span>
                    </fieldset>
                </form>

    <div id="results">

    </div>
  </body>
</html>

Here is the search_results.rhtml which is what gets displayed in the results div in search.rhtml

<% for tutors in @tutors %>
        <%= tutors.first_name %> <br/>
    <% end %>

And finally here is my controller and actions.

class TutorsController < ApplicationController

  def search
  end

  def search_results
     @tutors = Tutors.find_by_sql('SELECT * FROM tutors')
  end

end

What I want to do is basically create an effect that when the search results are loaded because of the ajax call that it would slide up. I am using jrails. Exactly how this site does it. http://keyonary.com/#/paste

Alex
  • 530
  • 3
  • 12
  • 28
  • So, what is your problem? Is it that you don't understand the Keyonary.com code? – kikito Jul 28 '10 at 08:00
  • My problem is that I am trying to replicate that jquery effect on the search results. Does anybody have any insights on that. – Alex Jul 28 '10 at 20:50

1 Answers1

0

In short, to get you started, you will need to do the following:

  • use observe_field on the input-field, which retrieves data from a controller-method and will update a certain div with the results
  • create a corresponding controller-method that will retrieve the items (use your search_results)
  • create a view for that controller-method that will show the data with the required effects and animation.
nathanvda
  • 49,707
  • 13
  • 117
  • 139