# Updating the dom

**URL:** <https://www.ruby-forum.com/t/updating-the-dom/93429>\
**Category:** Rails\
**Created:** [April 2, 2006, 11:03pm UTC](https://www.ruby-forum.com/t/updating-the-dom/93429 "2006-04-02T23:03:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![steveoco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/db5fbb/32.png) [@steveoco](https://www.ruby-forum.com/u/steveoco)\
**Post date:** [April 2, 2006, 11:03pm UTC](https://www.ruby-forum.com/t/updating-the-dom/93429/1 "2006-04-02T23:03:46Z")

</div>

Hi list,

Say I’ve got a page that lists the students names and grades. Grades are  
clickable using a form\_remote\_tag that then renders a new partial on the  
right hand side of the page that then lists the individual test scores  
for  
the particularly student. So far so good.

And lets say in the newly rendered right-hand section, I have another  
form\_remote\_tag that will allow me to input a new grade for that  
student.  
I’d like to set an onfocus event for that text input field that  
element.shows another div (that displays a help message, lets say).

The problem I am having is that I can’t get the onfocus event to work  
because – since the field is contained in a newly rendered div that  
wasn’t  
present when the page first loaded – its id doesn’t seem to be found in  
the  
dom and so the onfocus won’t trigger.

Is there a javascript command that can be used to refresh the dom when a  
partial is rendered?

Thanks,

Steve O.  
[http://www.smarkets.net](http://www.smarkets.net)

---

<div class="post-metadata">

**Author:** ![steveoco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/db5fbb/32.png) [@steveoco](https://www.ruby-forum.com/u/steveoco)\
**Post date:** [April 3, 2006, 2:53am UTC](https://www.ruby-forum.com/t/updating-the-dom/93429/2 "2006-04-03T02:53:56Z")

</div>

Steve O. wrote:

> > 
> 
> Is there a javascript command that can be used to refresh the dom when a  
> partial is rendered?

You shouldn’t have to refresh the dom. Just because you can’t “view  
source” to see the new element doesn’t mean that the browser doesn’t  
know it’s there.

---

<div class="post-metadata">

**Author:** ![steveoco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/db5fbb/32.png) [@steveoco](https://www.ruby-forum.com/u/steveoco)\
**Post date:** [April 3, 2006, 3:09am UTC](https://www.ruby-forum.com/t/updating-the-dom/93429/3 "2006-04-03T03:09:13Z")

</div>

Am 03.04.2006 um 02:53 schrieb charlie bowman:

> Steve O. wrote:
> 
> > > 
> > 
> > Is there a javascript command that can be used to refresh the dom  
> > when a  
> > partial is rendered?
> 
> You shouldn’t have to refresh the dom. Just because you can’t “view  
> source” to see the new element doesn’t mean that the browser doesn’t  
> know it’s there.

The “Web D.'s Tool Bar” for Firefox has a “View Generated  
Source” feature that allows you to see a HTML dump of the current DOM  
tree - and of course there always is Firefox’ and Mozilla’s great DOM  
tree viewer.

\*m

---

<div class="post-metadata">

**Author:** ![steveoco](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/db5fbb/32.png) [@steveoco](https://www.ruby-forum.com/u/steveoco)\
**Post date:** [April 3, 2006, 3:09am UTC](https://www.ruby-forum.com/t/updating-the-dom/93429/4 "2006-04-03T03:09:18Z")

</div>

Hey Steve - I suggest you pickup firebug (if your using firefox that  
is),

[https://addons.mozilla.org/extensions/moreinfo.php](https://addons.mozilla.org/extensions/moreinfo.php)?  
application=firefox&id=1843

amongst a bunch of great css, javascript and dom tools it’ll give you  
“View Source Live”.

Some other capabilities:

- Status bar icon shows you when there is an error in a web page
- A console that shows errors from JavaScript and CSS
- Log messages from JavaScript in your web page to the console (bye  
bye “alert debugging”)
- An JavaScript command line (no more “javascript:” in the URL bar)
- Spy on XMLHttpRequest traffic
- Inspect HTML source, computed style, events, layout and the DOM

cheers,  
Jodi
