[Rails] Re: How to pass current value of form field in link_to?

2009-03-06 Thread Jeba Momin
John Yerhot wrote: try this: %= link_to Preview Post, {:action = :preview, :id = @topic.id}, {:onclick = this.href +='?body='+encodeURIComponent($F ('id_of_the_form_element')); return true, :id = 'link', :target = _blank} % Hi John, I have a similar requirement. I need to pass the value

[Rails] Re: How to pass current value of form field in link_to?

2009-03-06 Thread Jeba Momin
Joe Peck wrote: Muchas gracias, that is close to perfect. The only problem is if I hit Preview Post multiple times, it keeps adding onto body, but I can fix that problem. It's times like these that I realize I need to learn more javascript. Hi Joe Can u please share wid me how did u

[Rails] Re: How to pass current value of form field in link_to?

2009-01-27 Thread Joe Peck
FWIW, I'm opening preview in another window. For right now, I plan on passing the current value of the text_field by setting params[:body] equal to it, but that doesn't seem to be the best idea. Is there a better way to pass the current value to the preview action? -- Posted via

[Rails] Re: How to pass current value of form field in link_to?

2009-01-27 Thread Greg
Where is the value in the text field coming from? If it's coming from your app (e.g. from the database or from a user passing parameters), then you can do this on the Rails side of things, and it seems most likely that you want to set an instance variable in the controller (e.g.

[Rails] Re: How to pass current value of form field in link_to?

2009-01-27 Thread Joe Peck
Greg wrote: Where is the value in the text field coming from? It's coming from whatever the user is typing in, so not from the database :( If you want the text field to dynamically update as the value of the text field is changed, then you should use Javascript, such as something along

[Rails] Re: How to pass current value of form field in link_to?

2009-01-27 Thread Joe Peck
Man, maybe I am making this more complicated than it should be. I just need to pass whatever is in the text_field to a preview action when I click a preview link. So I don't really need to dynamically update anything, but when preview is clicked, I want to get what is in the text_field and

[Rails] Re: How to pass current value of form field in link_to?

2009-01-27 Thread John Yerhot
%= link_to Preview Post, {:action = :preview, :id = @topic.id, :body = @body}, {:id = 'link', :target = _blank} % try this: %= link_to Preview Post, {:action = :preview, :id = @topic.id}, {:onclick = this.href +='?body='+encodeURIComponent($F ('id_of_the_form_element')); return true, :id =

[Rails] Re: How to pass current value of form field in link_to?

2009-01-27 Thread Joe Peck
John Yerhot wrote: %= link_to Preview Post, {:action = :preview, :id = @topic.id, :body = @body}, {:id = 'link', :target = _blank} % try this: %= link_to Preview Post, {:action = :preview, :id = @topic.id}, {:onclick = this.href +='?body='+encodeURIComponent($F

[Rails] Re: How to pass current value of form field in link_to?

2009-01-27 Thread John Yerhot
Glad it worked for you. :) On Jan 27, 3:47 pm, Joe Peck rails-mailing-l...@andreas-s.net wrote: John Yerhot wrote: %= link_to Preview Post, {:action = :preview, :id = @topic.id, :body = @body}, {:id = 'link', :target = _blank} % try this: %= link_to Preview Post, {:action = :preview,