Hello, I''ve just started using RoR this month, and am building a web app to help me learn the framework and the ruby language. I have a basic and hopefully straightforward question for you guys, since I can''t seem to find the answer on the internet or in my copy of agile. I thought I posted this same question here yesterday but now couldn''t find it, and was told that I''m not even in the group?? If someone remembers seeing a similar question, please do tell, I feel like it''s not here, but I hate it when people re-post questions so I hope I''m not doing the same. I have <div> tags with nested text setup in the page acting as buttons. I would like to use these buttons with link_to and link_to_remote. I haven''t yet figured out a way to get the generated anchor tags to nest other page elements inside. Now I have the buttons, but I have to click the text to get the link to work rather than having the whole div and everything in it act as a link. html tags: <div class="button"> Button </div> I''m doing this now: <div class="button"> <%= link_to_remote ''Button'', :url => { :action => ''add'', :id => person }, :update => ''added_people''%> </div> which of course generates something like <div class="button> <a... </div> and I want <a .... <div.. /div> </a> Any suggestions? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
RoaR_lion wrote:> Hello, I''ve just started using RoR this month, and am building a web > app to help me learn the framework and the ruby language. > > I have a basic and hopefully straightforward question for you guys, > since I can''t seem to find the answer on the internet or in my copy of > agile. > I thought I posted this same question here yesterday but now couldn''t > find it, and was told that I''m not even in the group?? If someone > remembers seeing a similar question, please do tell, I feel like it''s > not here, but I hate it when people re-post questions so I hope I''m > not doing the same. > > I have <div> tags with nested text setup in the page acting as > buttons. I would like to use these buttons with link_to and > link_to_remote. I haven''t yet figured out a way to get the generated > anchor tags to nest other page elements inside. Now I have the > buttons, but I have to click the text to get the link to work rather > than having the whole div and everything in it act as a link. > > html tags: > <div class="button"> > Button > </div> > > I''m doing this now: > > <div class="button"> > <%= link_to_remote ''Button'', > :url => { :action => ''add'', :id => person }, > :update => ''added_people''%> > </div> > > which of course generates something like > <div class="button> > <a... > </div> > > and I want > > <a .... > <div.. /div> > </a> > > Any suggestions? > >I haven''t tried this myself, but.... How about a helper. If you define a helper such as. def build_button(label) content_tag(:div, "some stuff inside the button, such as #{label}", :class => :button) end Then in your view, call <%= link_to_remote build_button(''Add''), :url => etc. etc. etc %> -- http://www.5valleys.com/ http://www.workingwithrails.com/person/8078 --~--~---------~--~----~------------~-------~--~----~ 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 Jon, I''m going to keep what I have for now because I''m not sure exactly how the final version will look, but I''ll keep your suggestion in mind. Thanks again. On Mar 25, 1:11 pm, Jon Garvin <jgarvin.li...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> RoaR_lion wrote: > > Hello, I''ve just started using RoR this month, and am building a web > > app to help me learn the framework and the ruby language. > > > I have a basic and hopefully straightforward question for you guys, > > since I can''t seem to find the answer on the internet or in my copy of > > agile. > > I thought I posted this same question here yesterday but now couldn''t > > find it, and was told that I''m not even in the group?? If someone > > remembers seeing a similar question, please do tell, I feel like it''s > > not here, but I hate it when people re-post questions so I hope I''m > > not doing the same. > > > I have <div> tags with nested text setup in the page acting as > > buttons. I would like to use these buttons with link_to and > > link_to_remote. I haven''t yet figured out a way to get the generated > > anchor tags to nest other page elements inside. Now I have the > > buttons, but I have to click the text to get the link to work rather > > than having the whole div and everything in it act as a link. > > > html tags: > > <div class="button"> > > Button > > </div> > > > I''m doing this now: > > > <div class="button"> > > <%= link_to_remote ''Button'', > > :url => { :action => ''add'', :id => person }, > > :update => ''added_people''%> > > </div> > > > which of course generates something like > > <div class="button> > > <a... > > </div> > > > and I want > > > <a .... > > <div.. /div> > > </a> > > > Any suggestions? > > I haven''t tried this myself, but.... > > How about a helper. If you define a helper such as. > > def build_button(label) > content_tag(:div, "some stuff inside the button, such as #{label}", > :class => :button) > end > > Then in your view, call <%= link_to_remote build_button(''Add''), :url => > etc. etc. etc %> > > --http://www.5valleys.com/ > > http://www.workingwithrails.com/person/8078--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---