Ian Cottee
2006-Jul-05 18:55 UTC
[Rails] RJS - Getting and Setting Form Element Values Question
I''m still a beginner with RJS so forgive me if this is a simple one - but certainly it doesn''t seem logical and googling has not led to . Given a field with an id of ''posting_subject'' I can do the following in my controller with RJS. render :update do | page | subject = ''this is really something page[''posting_subject''].value = subject end And we sing and rejoice. But why can''t I do render :update do | page | page[''comment_subject''].value = page[''posting_subject''].value end At the Javascript level the error is that we get ${''posting_subject''}.value() instead of ${''posting_subject''}.value And value is not a function. So, how can I *get* a value of a form element!? -- Posted via http://www.ruby-forum.com/.
Nanyang Zhan
2007-Oct-02 16:56 UTC
Re: RJS - Getting and Setting Form Element Values Question
Ian Cottee wrote:> render :update do | page | > page[''comment_subject''].value = page[''posting_subject''].value > endI want to know how to do this too. -- 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 -~----------~----~----~----~------~----~------~--~---
Nanyang Zhan
2007-Oct-03 02:31 UTC
Re: RJS - Getting and Setting Form Element Values Question
Nanyang Zhan wrote:> Ian Cottee wrote: > >> render :update do | page | >> page[''comment_subject''].value = page[''posting_subject''].value >> end > > I want to know how to do this too.I have just figured out how to do it!!!>render :update do |page| > page<< "$(''comment_subject'').value=$(''posting_subject'').value" >end-- 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 -~----------~----~----~----~------~----~------~--~---