Change color of links


#1

I have the following code in one of my views

"right", :url =>{ :action => :show_stats, :ladder_id => l.id }) %>

I want to change the default color of the link from blue to white. I
have tried using html_options like so

<%= link_to_remote( “#{l.name}”, :update => “right”, :url =>{ :action
=> :show_stats, :ladder_id => l.id }, :html_options => {:color =>
“white”}) %>

I have also tried wrapping the link_to in separate div tags and changing
the color there, but none of this has worked. The links are still the
default blue.

I am running rails 2.2.2


#2

On Tue, Jan 13, 2009 at 5:55 AM, Maulin pa
<removed_email_address@domain.invalid

wrote:

Posted via http://www.ruby-forum.com/.

Try: <%= link_to_remote( “#{l.name}”, :update => “right”, :url =>{
:action
=> :show_stats, :ladder_id => l.id }, :html_options => {:style =>
“color:white”}) %>
This applies a style attribute to the link and the CSS then handles the
color
You can’t wrap the call in divs because they won’t override a link’s
color,
that can only be done directly to the link.


Andrew T.
http://ramblingsonrails.com
http://www.linkedin.com/in/andrewtimberlake

“I have never let my schooling interfere with my education” - Mark Twain


#3

It looks like you have a broken div. Try this:

<%= link_to_remote( "#{l.name}", :update => "right", :url => { :action => :show_stats, :ladder_id => l.id }) %>

Then style it in the css with:

div#right a {color: #fff}

Matt

On Jan 12, 10:55 pm, Maulin pa removed_email_address@domain.invalid


#4

@Matthew,
The div tag is not broken, that was a typo on my part, sorry about that.
Styling the div in the css does not work.

@Andrew
I tried your syntax and that does not seem to change the link color
either. I tried putting the link_to_remote both inside and outside div
tags…no go.

Anybody else have any suggestions?


#5

On Wed, Jan 14, 2009 at 3:47 AM, Maulin pa
<removed_email_address@domain.invalid

wrote:

Anybody else have any suggestions?


Posted via http://www.ruby-forum.com/.

Sorry, another tired answer, try:
<%= link_to_remote( “#{l.name}”, {:update => “right”, :url =>{ :action
=>
:show_stats, :ladder_id => l.id }}, {:style => “color:white”} ) %>

The method signagure for link_to_remote is:
link_to_remote(name, options = {}, html_options = nil)

so you need to include the display text, a hash of options for the
remote
link and then a second hash for the html specific options so it’s best
to
use explicit hashes so you know which is which
link_to_remote( name, {}, {} )


Andrew T.
http://ramblingsonrails.com
http://www.linkedin.com/in/andrewtimberlake

“I have never let my schooling interfere with my education” - Mark Twain


#6

so you need to include the display text, a hash of options for the
remote
link and then a second hash for the html specific options so it’s best
to
use explicit hashes so you know which is which
link_to_remote( name, {}, {} )

Andrew, that worked perfectly. Woohoo! Thanks :slight_smile: