Can RoR's AJAX helpers do this?

Hi,

I want to type text into an input field then on enter, use AJAX to
update the value of an input field elsewhere on the screen.

‘observe_field’ allows me to watch a form field and dynamically update a
DIV. Is there a variation or other method to allow me to update a field
instead?

Lindsay B. wrote:

Is there a variation or other method to allow me to update a field
instead?

I have raw AJAX code that will do this. If there isn’t a RoR helper to
provide this functionality, is there a recommended RoR approach to
embedding Javascript in an app?

thanks
Lindsay

On Mar 21, 2006, at 15:24, Lindsay B. wrote:

I want to type text into an input field then on enter, use AJAX to
update the value of an input field elsewhere on the screen.

‘observe_field’ allows me to watch a form field and dynamically
update a
DIV. Is there a variation or other method to allow me to update a
field
instead?

Just for the record, note that it does not need to be a div, it
updates the content of any element with that id in that page. For
instance, to update the contents of some paragraph just assign an id
to it:

 <%= observe_field('foo', :url => { :action =>

‘my_ajax_updater’ }) %>

Inline elements can be changed directly or wrapped in ad-hoc spans as
well.

Is observe_field then suitable for your needs?

– fxn

Xavier N. wrote:

Is observe_field then suitable for your needs?

Yes, it is. Thanks Xavier!

On Mar 21, 2006, at 16:00, Xavier N. wrote:

Just for the record, note that it does not need to be a div, it
updates the content of any element with that id in that page. For
instance, to update the contents of some paragraph just assign an
id to it:

<%= observe_field('foo', :url => { :action =>  

‘my_ajax_updater’ }) %>

Oh sorry, that would be

 <%=
   observe_field(
     'my_field',
     :url => { :action => 'my_ajax_updater' },
     :update => 'foo'
   )
 %>
 <!-- ... and 100 lines below ... -->
 <p id="foo">...</p>

– fxn