I''m trying to drop the contents of @show_openers.subject and @show_upeners.body into the onlick event of my dropdown whenever it is changed. Is the solution to use the observe_field helper? If yes, what is the best approach? I''m new to programming and RoR and am having a REALLY hard time chaining it together in my head - any help is appreciated! CONTROLLER: def bar @show_openers = Opener.find(:all, :order => "description") end VIEW: <% form_for :bar, :url => { :action => :bar } do |form| %> <# when this is changed... %> <%= collection_select("openers", "opener_id", @show_openers, :id, :description ) %> <# ...update the HERE_IS_SUBJECT and HERE_IS_BODY values %> <%= submit_tag "insert opener", :onClick => "parent.target.document.form1.messagesubject.value=''HERE_IS_SUBJECT'', parent.target.document.form1.messagebody.value=''HERE_IS_BODY''" %> <% end %> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Here is a cleaner representation of the code: http://www.pastie.org/197264 thanks On May 14, 4:33 pm, RoRNoob <rorn...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m trying to drop the contents of @show_openers.subject and > @show_upeners.body into the onlick event of my dropdown whenever it is > changed. Is the solution to use the observe_field helper? If yes, what > is the best approach? I''m new to programming and RoR and am having a > REALLY hard time chaining it together in my head - any help is > appreciated! > > CONTROLLER: > > def bar > @show_openers = Opener.find(:all, :order => "description") > end > > VIEW: > > <% form_for :bar, :url => { :action => :bar } do |form| %> > <# when this is changed... %> > <%= collection_select("openers", "opener_id", > @show_openers, :id, :description ) %> > <# ...update the HERE_IS_SUBJECT and HERE_IS_BODY values %> > <%= submit_tag "insert opener", > :onClick => > "parent.target.document.form1.messagesubject.value=''HERE_IS_SUBJECT'', > parent.target.document.form1.messagebody.value=''HERE_IS_BODY''" %> > <% end %>--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ryan Bigg (Radar)
2008-May-15 01:04 UTC
Re: Use The observe_field Helper, or Something Else?
parent.target.document.form1.messagesubject.value is extremely ugly. Why not just do $(''messagesubject'').value? --~--~---------~--~----~------------~-------~--~----~ 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 tried your suggestion: http://www.pastie.org/197620 But it doesn''t work - my FireBug console says, "$("messagesubject") has no properties". Please keep in mind that I''m using frames (if that matters). I''m new to programming and especially JavaScript, so I''m a little slow right now. That being said, the main piece I''m trying to solve right now is how to get my messagebody and messagesubject tags to swap out on an onChange event from my drop down - basically, take the values for the currently select option and jam them into HERE_IS_SUBJECT and HERE_IS BODY. Thanks! On May 14, 6:04 pm, "Ryan Bigg (Radar)" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> parent.target.document.form1.messagesubject.value > > is extremely ugly. > > Why not just do $(''messagesubject'').value?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ryan Bigg (Radar)
2008-May-15 21:51 UTC
Re: Use The observe_field Helper, or Something Else?
Did you include the default javascript files by using <%= javascript_include_tag :defaults %> in your layout? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Yes - here are all 3 files that make up the framed page: http://www.pastie.org/198289 I''ve included them all under the same pastie, so I broke the pasted code up like so: <!-- -------------------- --> <!-- index.html.erb --> <!-- -------------------- --> ... code <!-- ---------------- --> <!-- bar.html.erb --> <!-- ---------------- --> ... code <!-- --------------------- --> <!-- target.html.erb --> <!-- --------------------- --> ...code Thanks! On May 15, 2:51 pm, "Ryan Bigg (Radar)" <radarliste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Did you include the default javascript files by using > > <%= javascript_include_tag :defaults %> in your layout?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---