Ajax on Rails
Subject:   correct code
Date:   2006-04-19 03:05:46
From:   gvlx

Checking for "observe_field" in gave me the answer.

If you use the following test code in the controller

def live_search
render_text "<p> "+ params.inspect + ".</p>"

I'll see the function 'observe_field' will not return the text unless told to do so (you were probably expected to retrive the field directly through the DOM).

change the rhtml to:

<label for="searchtext">Live Search:</label>
<%= text_field_tag :searchtext %>
<%= observe_field(:searchtext,
:frequency => 0.25,
:update => :search_hits,
:with => "searchtext",
:url => { :action => :live_search }) %>
<p>Search Results:</p>
<div id="search_hits"></div>

That will do it (until I learn to fetch the fields directly).

Best Regards

1 to 1 of 1
  1. correct code
    2006-04-19 03:09:48  gvlx [View]

1 to 1 of 1