Hi , I was trying to use link_to along with image_tag to setup a link that would open in an external window. But I was unable to make a link using both text & an image So my current workaround looks like this inside a partial where link is http://foo.com & text would be descriptive <img src="images/arrow.gif" border="0"/> <%= link_to(text, link, :popup =>true) %> ideally i would like to use the image_tag inside the link_to & make it cleaner. Would appreciate help from anyone on this, Thanks, Pete -- Posted via http://www.ruby-forum.com/.
Pete Gajria wrote:> Hi , > I was trying to use link_to along with image_tag > to setup a link that would open in an external window. > But I was unable to make a link using both text & an imageWhat does the original code look like? You should be able to do something like: link_to( image_tag(...), url ) -- Posted via http://www.ruby-forum.com/.
John Gray wrote:> Pete Gajria wrote: >> Hi , >> I was trying to use link_to along with image_tag >> to setup a link that would open in an external window. >> But I was unable to make a link using both text & an image > > What does the original code look like? You should be able to do > something like: > > link_to( image_tag(...), url )I tried the above which gives me an image with an href what i want is an image next to some text both of which link to the same url so something like this below...which didnt work for me link_to( image_tag(...), url, text ) aka link_to( image_tag(...), "http://www.cnn.com", "Read more news" ) -- Posted via http://www.ruby-forum.com/.
Pete Gajria wrote:> John Gray wrote: >> Pete Gajria wrote: >>> Hi , >>> I was trying to use link_to along with image_tag >>> to setup a link that would open in an external window. >>> But I was unable to make a link using both text & an image >> >> What does the original code look like? You should be able to do >> something like: >> >> link_to( image_tag(...), url ) > > I tried the above which gives me an image with an href > what i want is an image next to some text both of which link to the same > url > so something like this below...which didnt work for me > link_to( image_tag(...), url, text ) > > aka > > link_to( image_tag(...), "http://www.cnn.com", "Read more news" )Ah, I see. The only way I know to do that is to use two link_to calls, one as above and another using a text string instead of image_tag. -- Posted via http://www.ruby-forum.com/.
Rob Biedenharn
2006-Jun-26 20:58 UTC
[Rails] Re: Using link_to with an image tag & link text
On Jun 9, 2006, at 7:56 PM, John Gray wrote:> Pete Gajria wrote: >> John Gray wrote: >>> Pete Gajria wrote: >>>> Hi , >>>> I was trying to use link_to along with image_tag >>>> to setup a link that would open in an external window. >>>> But I was unable to make a link using both text & an image >>> >>> What does the original code look like? You should be able to do >>> something like: >>> >>> link_to( image_tag(...), url ) >> >> I tried the above which gives me an image with an href >> what i want is an image next to some text both of which link to >> the same >> url >> so something like this below...which didnt work for me >> link_to( image_tag(...), url, text ) >> >> aka >> >> link_to( image_tag(...), "http://www.cnn.com", "Read more news" ) > > Ah, I see. The only way I know to do that is to use two link_to calls, > one as above and another using a text string instead of image_tag.Not so, just do this: (note the ''+'' btwn image_tag and text) link_to( image_tag(...) + "http://www.cnn.com", "Read more news" ) -Rob
Try doing this: link_to "Read more news #{image_tag(....)}", url ) Justin On 6/9/06, Pete Gajria <petegajria@yahoo.com> wrote:> > John Gray wrote: > > Pete Gajria wrote: > >> Hi , > >> I was trying to use link_to along with image_tag > >> to setup a link that would open in an external window. > >> But I was unable to make a link using both text & an image > > > > What does the original code look like? You should be able to do > > something like: > > > > link_to( image_tag(...), url ) > > I tried the above which gives me an image with an href > what i want is an image next to some text both of which link to the same > url > so something like this below...which didnt work for me > link_to( image_tag(...), url, text ) > > aka > > link_to( image_tag(...), "http://www.cnn.com", "Read more news" ) > > > > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Justin Chen Two-Bit Operation LLC http://www.twobitoperation.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060705/74c9b159/attachment.html