render :update do |page|
page.replace_html 'someDiv', :partial => 'somePartial'
I need to edit this to verify that someDiv exists before I go
replacing_htmling it. I’m at a loss to figure out if this can be
done. Any ideas?
are you not in control of the content of your pages? As far as I
know, the only way to do something like this would be to read the
entire page and search to make sure the div exists before continuing.
Unfortunately you can’t just execute the rjs call and expect it to
throw an exception on error (the exception is thrown outside the
context of rails and handled directly by the prototype library)
You can use the following library to allow you to parse your html files:
but of course it’ll be faster when operating on local files than
through using open-uri. But this is an expensive operation which you
really want to avoid if possible.
Parse the entire page with hpricot? That’s rather silly. You can use
of an element with an id, and you can use use the concatenation