Topic: Changing the color of a control after a page is rendered
This shouldn't be too hard, but I can't seem to find a reference to how to do it. (I am new to both Rails and js, so forgive me if this is incredibly lame).
When a user loads my page, I want to highlight the table cell they were last working with when they saved the form last.
I have tried putting "window.onload = InitDay()" near the top of my script (as well as at the end of my script), as well as "window.afterrender = InitDay()" but when the page is loaded, InitDay is called before the page is rendered, so I get an error when InitDay() tries to reference a table cell, I believe because the table has not yet been rendered.
The code in InitDay is:
x= document.getElementById(lastday) //lastday is the last day that was being edited and is the name of the appropriate table cell
xx = x.className // this line results in the error 'x is null'
When this code is executed the table calendar is not yet rendered, so I presume this is why 'x is null'.
So, how does one invoke a javassript function to run after a page has completed rendering?
Thanks in advance for any help. --Fred
Last edited by fredrated (2012-01-13 13:44:40)