ONJava.com -- The Independent Source for Enterprise Java
oreilly.comSafari Books Online.Conferences.

advertisement

AddThis Social Bookmark Button
Article:
  Ajax on Rails
Subject:   correct code
Date:   2006-04-19 03:02:21
From:   gvlx
Hi!


Checking for "observe_field" in http://api.rubyonrails.org/ gave me the answer.


If you use the following test code in the controller


def live_search
render_text "

"+ params.inspect + ".

"
end


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

Search Results:


<div id="search_hits"></div>


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


Best Regards
G.


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

1 to 1 of 1