Forum: Ruby on Rails Live Search problems - HELP

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
1e2dd87a31c5d3e07adc9efa375f4dc4?d=identicon&s=25 rh (Guest)
on 2006-03-18 01:53
I'm trying to make a live search for my site.  Nothing is working, and
I'm getting a javascript error that says "Form is not defined", but I
don't think that's my only problem.

This is my view:

  <%= form_remote_tag(
      :url => {:controller => 'inventory', :action => 'search'},
      :update => "results" )%>
    <input type="text" id="search" name="search" size="40" value="" />
    <img id="loading" src="/images/loading.gif" alt="Loading..."
style="display:
     none;" />
  <% end_form_tag %>

  <%= observe_field( 'search', :frequency => 0.5,
      :url => {:controller => 'inventory', :action => 'search'},
      :update => :results,
      :loading => "Element.show('loading');",
      :complete => "Element.hide('loading');",
      :with => "'search=' + escape($F('search'))"
      ) %>

  <div id="results"></div>

Here's my controller:

  def search
    if @params['search']
    @items = Content.find(:all,
             :conditions => [ 'LOWER(post) LIKE ? or LOWER(title) LIKE
?',
                '%' + @params['search'].downcase + '%',
                '%' + @params['search'].downcase + '%'],
             :order => "id desc")
    @mark_term = @params['search']
    render_without_layout
    end
  end



This might be way off, but I'm trying to follow examples and what I
*think* might work.  I can't get anything at all so far, though.

Can someone please help me out???

Thanks!
This topic is locked and can not be replied to.