RE: Help with observe_field


#1

Marcus,

I believe your field has to be inside a “start_form_tag” and
“end_form_tag” pair before you can use the “observe” on it.

Nathan


From: removed_email_address@domain.invalid
[mailto:removed_email_address@domain.invalid] On Behalf Of Marcus
Blankenship
Sent: Tuesday, May 23, 2006 11:03 AM
To: removed_email_address@domain.invalid
Subject: [Rails] Help with observe_field

Folks,

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

View: search.rhtml
Search:
<%= text_field_tag :search %>
<%= observe_field(:search,
:frequency => 0.25,
:update => :search_hits,
:url => { :action => “search”}) %>

Search Results:

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})})