Ajax observe_field not vorking on Rails

down vote favorite

I am trying to create some kind of search in my ruby on rails application and I want to add ajax support. I want when a user types in a search box a word, ajax automatically generates the results. And I have searched almost all internet and I couldn't find answer to following question:

When I type into my text area nothing happens. It is like ajax is not working at all. Tre problem is in observe_field which should observe my id= 'query' but it seem like it not doing anything

I am using Prototype 1.6.1 and the newest version of rails. The code I wrote is:


    <form name="sform" action="" style="display:inline;"> <label for="item_name">Filter on Property No : </label> <%= text_field_tag(:query, params['query'], :size => 10, :id => 'query' ) %> </form>

<%= image_tag("/images/system/blue_small.gif",               :align => "absmiddle",               :border => 0,               :id => "spinner",               :style =>"display: none;" ) %> </p>

<%= observe_field 'query', :frequency => 1,          :update => 'table',          :before => "$('#spinner').show()",          :success => "$('#spinner').hide()",          :url => {:action => 'list'},          :with => 'query' %>

<div id="table"> <%= render :partial => "items_list" %> </div>

And my controler is:

  def list

    sort = case params['sort']            when "Title" then "title"            when "address" then "address"            when "close date" then "close_date"            when "property_no_reverse" then "property_no DESC"            when "address_reverse" then "address DESC"            when "close_date_reverse" then "close_date DESC"            end

    conditions = ["title LIKE ?", "%#{params[:query]}%"] unless params[:query].nil?

    @total = Message.count(:conditions => conditions)      @accounts = Message.paginate :page => params[:page], :per_page => 10, :order => sort, :conditions => conditions     if request.xml_http_request?       render :partial => "items_list", :layout => false     end


I would greatly appreciate any help I can get!