Hello folks. I''m starting to Ruby on Rails and I have a doubt about a very straightforward application. Suppose I have a form whose fields are all blank. On this same page, I have another form on which I can query for some information from my database. Is there any nice way on which I can gather the query results and fill the first form''s fields with it using AJAX, without having to write handling functions in Javascript, only using Ruby ? The closer I got from it was putting the first form inside a <div> and call form_remote_tag function, whose :action parameter was a function that wrote all form''s html code again (filling the fields). I am thinking about writing a function that writes a xml document with the results instead of the whole html code for the form, then I would have just to write a single javascript function to handle it. But I wonder whether exists some ellegant way to do it in rails. Thanks Felipe --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Sure, but are you sure this is the right way to get what you want? you can access any DOM element with the page hash. ex: html: <form> <input type="text" id="monkey" /> </form> RJS: page[:monkey].value = "likes bananas" -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I''ve just solved this problem creating a layout named _form2.rhtml with the source code of the first form and writing render :partial => form2 in the controller, just after retrieving the information I needed. Very nice =) Thank you all. Felipe On 2/12/07, Elad Meidar <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > > Sure, > but are you sure this is the right way to get what you want? > > you can access any DOM element with the page hash. > > ex: > > html: > <form> > <input type="text" id="monkey" /> > </form> > > > RJS: > > page[:monkey].value = "likes bananas" > > -- > Posted via http://www.ruby-forum.com/. > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---