Link_to nesting

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

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:

Button

I’m doing this now:

<%= link_to_remote 'Button', :url => { :action => 'add', :id => person }, :update => 'added_people'%>

which of course generates something like

<div class="button> <a... </div> <p>and I want</p> <p><a …<br> <div… /div><br> </a></p> <p>Any suggestions?</p>

RoaR_lion wrote:

not doing the same.
Button
which of course generates something like
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

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.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs