Forum: Ruby on Rails RJS not updating styles

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Befa945ac6d3bf13c4b41657e8558f85?d=identicon&s=25 Mike Dershowitz (dersh53)
on 2007-04-27 12:31

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:

<LgTextWh>"<%=h q.text %>" by <%=h %>, <%=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:

<div id="leftHeader">
    <table width="100%" border="0" cellpadding="0" cellspacing="0" >
      <td width="50%" align="left" valign="top">
    <%= image_tag "logo.gif" %>
    <td width="50%" align="right" valign="center">
    <%= periodically_call_remote(:url => {:controller => tasks:action =>
                :frequency => 60) %>
    <div id="quote"></div>

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}

Thank you very much in advance for your help!

A2c85dc5ee81b12e3cc0a6522e8d079d?d=identicon&s=25 Chris Hall (au5lander)
on 2007-04-27 13:33
(Received via mailing list)
<LgTextWh>"<%=h q.text %>" by <%=h %>, <%=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


/* 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;

<span class="i-am-a-class">...</span>


<div id="menu">...</div>

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

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

<span class="LgTextWh">"<%=h q.text %>" by <%=h %>, <%=h q.year
This topic is locked and can not be replied to.