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!
--
Posted via http://www.ruby-forum.com/.