# RJS not updating styles

**URL:** <https://www.ruby-forum.com/t/rjs-not-updating-styles/93093>\
**Category:** Rails\
**Created:** [April 27, 2007, 12:31pm UTC](https://www.ruby-forum.com/t/rjs-not-updating-styles/93093 "2007-04-27T12:31:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![miked](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ed655f/32.png) [@miked](https://www.ruby-forum.com/u/miked)\
**Post date:** [April 27, 2007, 12:31pm UTC](https://www.ruby-forum.com/t/rjs-not-updating-styles/93093/1 "2007-04-27T12:31:47Z")

</div>

Hello:

I have an RJS tied to periodic update in one of my controllers. I want  
the output text to be stylized, so I have the code in the RJS wrapped  
in custom style tags:

“\<%=h q.text %\>” by \<%=h q.author %\>, \<%=h q.year  
%\>

For some reason, this style isn’t being applied with each periodic  
update, although the HTML is definately being updated, as the data is  
refreshing, nor is it changing when I change the style in the RJS. I  
have also tried applying the style around the div that receives the HTML  
injection from the RJS, but that’s not working either.

Here’s the style definition from my css:

LgTextWh {font-size:125%; font-weight: normal; color: white}

[NOTE: these are purposely not children of “body” as I needed more  
flexibility in setting text standards.]

And the code around the periodic update in my view:

| \<%= image\_tag "logo.gif" %\> | \<%= periodically\_call\_remote(:url =\> {:controller =\> tasks:action =\> 'quotes\_panel'}, :frequency =\> 60) %\> 

 |

and the method that the periodic remote call uses:

def quotes\_panel  
@quote = Quote.find\_by\_sql(“SELECT \* FROM quotes ORDER BY RAND()  
LIMIT 1”)[0]  
render :update do |page|  
page[‘quote’].replace\_html :partial =\> ‘quote\_rand’, :locals =\> {  
:q =\> @quote}  
end  
end

Thank you very much in advance for your help!

Mike

---

<div class="post-metadata">

**Author:** ![miked](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ed655f/32.png) [@miked](https://www.ruby-forum.com/u/miked)\
**Post date:** [April 27, 2007, 1:33pm UTC](https://www.ruby-forum.com/t/rjs-not-updating-styles/93093/2 "2007-04-27T13:33:28Z")

</div>

“\<%=h q.text %\>” by \<%=h q.author %\>, \<%=h q.year  
%\>

css doesn’t work that way. you can’t define your own tags, you can  
create style classes or apply styles to specific elements via the  
element itself or an id attribute

ex:

/\* class style \*/  
.i-am-a-class {  
font-size: 1.2em;  
}

/\* all h1 tags get this style \*/  
h1 {  
font-size: 1.6em;  
}

/\* style via id attribute\*/  
#menu {  
text-align: left;  
}

…

# ...

...

so from what you have posted, you probably want something like:

.LgTextWh {font-size:125%; font-weight: normal; color: white}

“\<%=h q.text %\>” by \<%=h q.author %\>, \<%=h q.year  
%\>
