I have a form and I am trying to pass a next_question param which will hold a value that is returned by a javascript function. Is this possible? I am new to using :with and javascript and have read documentation on it as well as an entire page explaining it with examples but I still dont really understand how to do this, or if it is even possible. :with => "''next_question=''javascript: getNextQuestion()" Thanks in advance, chris -- 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 -~----------~----~----~----~------~----~------~--~---
Chris Hickman wrote:> I have a form and I am trying to pass a next_question param which will > hold a value that is returned by a javascript function. Is this > possible? I am new to using :with and javascript and have read > documentation on it as well as an entire page explaining it with > examples but I still dont really understand how to do this, or if it is > even possible. > > > :with => "''next_question=''javascript: getNextQuestion()" > > > Thanks in advance, > > chrisWhat about the :compete call back. When using form_remote_tag I use :complete to clear a text_field for example. I imagine if you had a div with an id you could use that javaScript function to change the innerText of that div upon complete to add the next question. Hope this helps, -S -- 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 -~----------~----~----~----~------~----~------~--~---
On 9 Jun 2008, at 17:43, Chris Hickman wrote:> > I have a form and I am trying to pass a next_question param which will > hold a value that is returned by a javascript function. Is this > possible? I am new to using :with and javascript and have read > documentation on it as well as an entire page explaining it with > examples but I still dont really understand how to do this, or if it > is > even possible. > > > :with => "''next_question=''javascript: getNextQuestion()" >I''ve got some examples here: http://www.spacevatican.org/2008/5/17/with-or-without-you-link_to_remote-s-mysterious-parameter it is possible - what you don''t seem to have grasped yet is that the entirety of the :with parameter should be a piece of javascript code. Fred> > Thanks in advance, > > chris > -- > 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 -~----------~----~----~----~------~----~------~--~---
Fred, I''m sorry, that was the page I was reading. I found a link to it in another forum. I have tried several different ways of doing this and none of them seem to be working for me. From one of the last 2 examples on your page it seems like the following should work but I am not having any luck. :with => "''next_question=''+getNextQuestion()" I am glad to hear this is possible though. Thanks -- 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 -~----------~----~----~----~------~----~------~--~---
On 9 Jun 2008, at 18:07, Chris Hickman wrote:> > Fred, > > I''m sorry, that was the page I was reading. I found a link to it in > another forum. I have tried several different ways of doing this and > none of them seem to be working for me. From one of the last 2 > examples > on your page it seems like the following should work but I am not > having > any luck. > > > :with => "''next_question=''+getNextQuestion()" >The problem is probably the getNextQuestion is not returning something that is uri encoded (or not returning anything at all). Remember that in javascript you need an explicit return statement, and use encodeURIComponent. Fred> I am glad to hear this is possible though. > > Thanks > > -- > 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 -~----------~----~----~----~------~----~------~--~---
One last question and then I am giving up. It seems like nothing is getting passed over at all. The following should pass next_question to the controller with a value of 6. In the controller I should be able to access it by saying params[:free_response][:next_question] correct? <% form_for(:free_response, :url => {:action => ''next'', :question => @question.id}, :with => "''next_question=''+encodeURIComponent(6)") do |form| %> Sorry for all the questions I am just completely lost on this one. I tried the encodeURIComponent() before and nothing changed so I kept changing it around. Chris -- 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 -~----------~----~----~----~------~----~------~--~---
On 9 Jun 2008, at 18:40, Chris Hickman wrote:> > One last question and then I am giving up. It seems like nothing is > getting passed over at all. The following should pass next_question > to > the controller with a value of 6. In the controller I should be > able to > access it by saying params[:free_response][:next_question] correct? > > <% form_for(:free_response, :url => {:action => ''next'', :question => > @question.id}, :with => "''next_question=''+encodeURIComponent(6)") do > |form| %> > > Sorry for all the questions I am just completely lost on this one. I > tried the encodeURIComponent() before and nothing changed so I kept > changing it around.:with is only for remote_form_for, link_to_remote etc... in your case i''d probably use an onsubmit to update a hidden field Fred> > Chris > -- > 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 -~----------~----~----~----~------~----~------~--~---
Thanks for your time and patience. -- 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 -~----------~----~----~----~------~----~------~--~---