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? -- Posted via http://www.ruby-forum.com/.
Lindsay Boyd 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 -- Posted via http://www.ruby-forum.com/.
On Mar 21, 2006, at 15:24, Lindsay Boyd 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'' }) %> <!-- ... and 100 lines below ... --> <p id="foo">...</p> Inline elements can be changed directly or wrapped in ad-hoc spans as well. Is observe_field then suitable for your needs? -- fxn
On Mar 21, 2006, at 16:00, Xavier Noria wrote:> On Mar 21, 2006, at 15:24, Lindsay Boyd 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'' }) %> > <!-- ... and 100 lines below ... --> > <p id="foo">...</p>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