Updating the dom

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

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.

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

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

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs