Hi, I have a text area with id:"text_area" and in a link_to_remote tag I want to add content into the text area I tried (Syntax was correct though not the exact one as below) link_to_remote (update: "text_area", url : { action => "update_text"}, position: bottom ) The update_text action in the controller had render :text => "This is new line" THis does not work for text area, any help in the aspect would be good. If I have a div instead of text area it works but not for the text_area only. Thanks, Sudhindra -- 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 -~----------~----~----~----~------~----~------~--~---
You dont need an Ajax call for this. RJS is enough. in helper def add_text_link(name) link_to_function name do |page| page[:text_area] = "This is new line" end end in view <%= add_text_link "Insert text into text area using JS" %> On Mar 12, 7:18 pm, Sudhi Kulkarni <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi, > > I have a text area with id:"text_area" and in a link_to_remote tag I > want to add content into the text area > > I tried (Syntax was correct though not the exact one as below) > > link_to_remote (update: "text_area", > url : { action => "update_text"}, > position: bottom > ) > > The update_text action in the controller had > > render :text => "This is new line" > > THis does not work for text area, any help in the aspect would be good. > If I have a div instead of text area it works but not for the text_area > only. > > Thanks, > Sudhindra > -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ram wrote:> You dont need an Ajax call for this. RJS is enough. > in helper > > def add_text_link(name) > link_to_function name do |page| > page[:text_area] = "This is new line" > end > end > > in view > > <%= add_text_link "Insert text into text area using JS" %> > > On Mar 12, 7:18?pm, Sudhi Kulkarni <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>Hi Ram, Thanks for the help... this works but I have another question now what if I need to append into the text area instead of replacing the content? Thanks, Sudhi -- 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 -~----------~----~----~----~------~----~------~--~---
rubyguy-DaQTI0RpDDMAvxtiuMwx3w@public.gmane.org
2009-Mar-17 07:21 UTC
Re: Lin_to_remote and update a text area
On 17 Mar., 07:02, Sudhi Kulkarni <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi Ram, > > Thanks for the help... this works but I have another question now what > if I need to append into the text area instead of replacing the content?def add_text_link(name) link_to_function name do |page| page[:text_area] << "This is new line" end end -- Cheers, David Knorr http://twitter.com/rubyguy --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
rubyguy-DaQTI0RpDDMAvxtiuMwx3w@public.gmane.org wrote:> On 17 Mar., 07:02, Sudhi Kulkarni <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > wrote: >> Hi Ram, >> >> Thanks for the help... this works but I have another question now what >> if I need to append into the text area instead of replacing the content? > > def add_text_link(name) > link_to_function name do |page| > page[:text_area] << "This is new line" > end > end > > -- > Cheers, > David Knorr > http://twitter.com/rubyguyHi David, I tried this but it does not work. For the text area update to work with IE for a single line I had to do link_to_function name do |page| page[:text_area].value = "Hello world" end Please note the .value that I use, without using .value it does not work ... so for appending I tried page[:text_area].value << "This is new line" This also did not work. Need further help... Thanks, Sudhindra -- 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 -~----------~----~----~----~------~----~------~--~---
rubyguy-DaQTI0RpDDMAvxtiuMwx3w@public.gmane.org
2009-Mar-17 14:46 UTC
Re: Lin_to_remote and update a text area
On 17 Mar., 11:18, Sudhi Kulkarni <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> ruby...-DaQTI0RpDDMAvxtiuMwx3w@public.gmane.org wrote: > > On 17 Mar., 07:02, Sudhi Kulkarni <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > wrote: > Hi David, > > I tried this but it does not work. For the text area update to work with > IE for a single line I had to do > > link_to_function name do |page| > page[:text_area].value = "Hello world" > end > > Please note the .value that I use, without using .value it does not work > ... so for appending I tried > > page[:text_area].value << "This is new line" > > This also did not work. Need further help...page[:text_area].insert_html :bottom, "The new line" This should work properly. The documentation for the methods available in RJS is located here, if you want to take a closer look: http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper/JavaScriptGenerator/GeneratorMethods.html -- Cheers, David Knorr http://twitter.com/rubyguy --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
> render :text => "This is new line"You could say: render :inline => "<%= text_field ''test'', ''name'' %>" This would just re-populate the div you are trying to update with the above helper code. -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 -~----------~----~----~----~------~----~------~--~---
Shandy Nantz wrote:>> render :text => "This is new line" > > You could say: > > render :inline => "<%= text_field ''test'', ''name'' %>" > > This would just re-populate the div you are trying to update with the > above helper code. > > -SHi, Thanks for all the inputs. The following line works fine page.insert_html :bottom,''text_area'', "Hello world" That raises one more question I want the text in the text_area to look like ----------- Hello world1 Hello world2 hello world3 ------------ So to get this if I add page.insert_html :bottom,''text_area'', "Hello world\r\n" The line breaks don''t display in the text area ... how do I get that working? Thanks, Sudhindra -- 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 -~----------~----~----~----~------~----~------~--~---
its inner HTML. So use <br/> On Mar 18, 8:53 am, Sudhi Kulkarni <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Shandy Nantz wrote: > >> render :text => "This is new line" > > > You could say: > > > render :inline => "<%= text_field ''test'', ''name'' %>" > > > This would just re-populate the div you are trying to update with the > > above helper code. > > > -S > > Hi, > > Thanks for all the inputs. The following line works fine > > page.insert_html :bottom,''text_area'', "Hello world" > > That raises one more question > > I want the text in the text_area to look like > ----------- > Hello world1 > Hello world2 > hello world3 > ------------ > > So to get this if I add > page.insert_html :bottom,''text_area'', "Hello world\r\n" > > The line breaks don''t display in the text area ... how do I get that > working? > > Thanks, > Sudhindra > -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ram wrote:> its inner HTML. So use <br/> > > On Mar 18, 8:53�am, Sudhi Kulkarni <rails-mailing-l...@andreas-s.net>Hi Ram, I tried <br/> but once I add br it says it is an RJS Error. Don''t know why ... the snippet I used is link_to_function name do |page| page.insert_html :bottom,''text_area'', "Hello world <br/>" end Thanks, Sudhindra -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
My suggestion was just a try.Just try everything you can think of with your code. its not going to affect anything else as far as i can see. It would help if you tell us more about what the error was. Take a look at prototype.js api docs. Wouldnt take more than a couple of hours to go through the whole thing and it really helps. www.prototypejs.org/api Also look out for RJS tutorials. Railscasts episodes 43-45 are good ones. www.railscasts.com/episodes/43 Here''re a few RJS cheatsheets for quick reference http://thebitt.com/dropbox/rails/rjs_cheatsheet.pdf, http://slash7.com/assets/2006/10/8/RJS-Demistified_Amy-Hoy-slash7_1.pdf Search the net thoroughly. More often than not, you can find a solution or the question has already been asked on some forum. And when you get errors that you cant resolve, post as much about them as you can so that others can help you. On Mar 18, 11:38 am, Sudhi Kulkarni <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Ram wrote: > > its inner HTML. So use <br/> > > > On Mar 18, 8:53 am, Sudhi Kulkarni <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > Hi Ram, > > I tried <br/> but once I add br it says it is an RJS Error. Don''t know > why ... the snippet I used is > > link_to_function name do |page| > page.insert_html :bottom,''text_area'', "Hello world <br/>" > end > > Thanks, > Sudhindra > -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Ram wrote:> My suggestion was just a try.Just try everything you can think of with > your code. its not going to affect anything else as far as i can see. > It would help if you tell us more about what the error was. > > Take a look at prototype.js api docs. Wouldnt take more than a couple > of hours to go through the whole thing and it really helps. > www.prototypejs.org/api > > Also look out for RJS tutorials. Railscasts episodes 43-45 are good > ones. www.railscasts.com/episodes/43 > > Here''re a few RJS cheatsheets for quick reference > http://thebitt.com/dropbox/rails/rjs_cheatsheet.pdf, > http://slash7.com/assets/2006/10/8/RJS-Demistified_Amy-Hoy-slash7_1.pdf > > Search the net thoroughly. More often than not, you can find a > solution or the question has already been asked on some forum. > And when you get errors that you cant resolve, post as much about them > as you can so that others can help you. > > On Mar 18, 11:38�am, Sudhi Kulkarni <rails-mailing-l...@andreas-s.net>Hi Ram, The articles you sent and the previous posts helped me find this to get the stuff working but that leaves me with a new problem With the below RJS def add_text_link(name) link_to_function name do |page| begin page << <<-''end'' $(''text_area'').value += "\n Hello world" ; end end I added above code in the RJS, this works but if I need to use the name parameter that is passed in how do I do it? I tried #{name} but no luck... Thanks, Sudhindra -- 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
$(''text_area'').value += ("\n Hello world" + name) that should work or try.. $(''text_area'').value += ("\n Hello world" + "#{name} ") But seriously.. keep trying different ways to get the result. you''ll hit it just by brute force. On Mar 19, 3:48 pm, Sudhi Kulkarni <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Ram wrote: > > My suggestion was just a try.Just try everything you can think of with > > your code. its not going to affect anything else as far as i can see. > > It would help if you tell us more about what the error was. > > > Take a look at prototype.js api docs. Wouldnt take more than a couple > > of hours to go through the whole thing and it really helps. > >www.prototypejs.org/api > > > Also look out for RJS tutorials. Railscasts episodes 43-45 are good > > ones.www.railscasts.com/episodes/43 > > > Here''re a few RJS cheatsheets for quick reference > >http://thebitt.com/dropbox/rails/rjs_cheatsheet.pdf, > >http://slash7.com/assets/2006/10/8/RJS-Demistified_Amy-Hoy-slash7_1.pdf > > > Search the net thoroughly. More often than not, you can find a > > solution or the question has already been asked on some forum. > > And when you get errors that you cant resolve, post as much about them > > as you can so that others can help you. > > > On Mar 18, 11:38 am, Sudhi Kulkarni <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > Hi Ram, > > The articles you sent and the previous posts helped me find this to get > the stuff working but that leaves me with a new problem > > With the below RJS > > def add_text_link(name) > link_to_function name do |page| > begin > page << <<-''end'' > $(''text_area'').value += "\n Hello world" ; > end > end > > I added above code in the RJS, this works but if I need to use the name > parameter that is passed in how do I do it? > > I tried #{name} but no luck... > > Thanks, > Sudhindra > -- > Posted viahttp://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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---