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: rails-bounces@lists.rubyonrails.org
[mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Marcus
Blankenship
Sent: Tuesday, May 23, 2006 11:03 AM
To: rails@lists.rubyonrails.org
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__
<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})})
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
http://wrath.rubyonrails.org/pipermail/rails/attachments/20060523/344d3342/attachment.html