Forum: Ruby on Rails Help with observe_field

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.
Marcus B. (Guest)
on 2006-05-23 20:06
(Received via mailing list)
Folks,

When I use observe_field, I get a javascript error "Form is not
defined".  Any thoughts?


__View: search.rhtml__
<label for="search">Search:</label>
<%= text_field_tag :search %>
<%= observe_field(:search,
                 :frequency => 0.25,
                 :update => :search_hits,
                 :url => { :action => "search"}) %>
<p>Search Results:</p>
<div id="search_hits"></div>



__Controller: search_controller.rb__
class SearchController < ApplicationController
  WORDLIST = %w(Rails is a full-stack, really cool, open-source, free
thingy!)
  def search
    @phrase = request.raw_post || request.query_string
    matcher = Regexp.new(@phrase)
    @results = WORDLIST.find_all {|word|word =~ matcher}
    render(:layout => false)
  end
end


__Error: Form is not defined__

__Line error occurs__
new Form.Element.Observer('search', 0.25, function(element, value) {new
Ajax.Updater('search_hits', '/facilities/search', {asynchronous:true,
evalScripts:true, parameters:value})})
This topic is locked and can not be replied to.