Ajax/DHTML: How to replace a <tr>...</tr> in a table?

Hi,

how would I replace a complete table row including the


tags with Ajax/DHTML ?

The :update parameter to remote_function() takes the ID of a HTML
element, but can replace only the innerHTML part, i.e. the stuff
between

and , but not the tag itself (required to
change its parameters).

regards

don’t use the :update param then, just call your ajax action and tell
the browser which tag to replace by it’s id (requires unique id for each
table row)

something like:

page[“tr_002”].replace_html(“

new content”)

should work

On 28 May 2008, at 10:52, Hadmut wrote:

Hi,

how would I replace a complete table row including the


tags with Ajax/DHTML ?

The :update parameter to remote_function() takes the ID of a HTML
element, but can replace only the innerHTML part, i.e. the stuff
between

and , but not the tag itself (required to
change its parameters).

Perhaps the obvious solution is to not use :update; just write some js
that will use Element.replace instead of Element.update

Fred

how would I replace a complete table row including the


tags with Ajax/DHTML ?

I thought IE could not replace a table row. Maybe I misremember some
restriction
there…

On May 28, 2008, at 7:36 AM, Phlip wrote:

how would I replace a complete table row including the …
tags with Ajax/DHTML ?

I thought IE could not replace a table row. Maybe I misremember some
restriction
there…

Do you have … tags surrounding your rows? If you
have trouble, that might be some of it.

-Rob

Rob B. http://agileconsultingllc.com
[email protected]

On May 28, 12:10 pm, Frederick C. [email protected]
wrote:

Perhaps the obvious solution is to not use :update; just write some js
that will use Element.replace instead of Element.update

That way looks good, but how exactly would I call this?

I guess the best way would be to call it from :success, but how could
I get the HTML fragment passed by the server then?

regards

page[“tr_002”].replace_html(“

new content”)

should work

Good point, but the docs say that replace_html replaces the inner
part only, not the element.

Then use .replace

Tips: put an ID into your TR, such as tr_002, so the system knows what
to
replace. And put the TR into a partial, so you can use .replace :tr_002,
:partial => …

On May 28, 12:06 pm, Thorsten M. <rails-mailing-l…@andreas-
s.net> wrote:

something like:

page[“tr_002”].replace_html(“new content”)

should work

Good point, but the docs say that replace_html replaces the inner
part only, not the element.

regards

Phlip wrote:

how would I replace a complete table row including the


tags with Ajax/DHTML ?

I thought IE could not replace a table row. Maybe I misremember some
restriction
there…

That’s right, it’s not possible to replace tr in IE.

Replace table.

On 28 May 2008, at 23:37, Hadmut wrote:

That way looks good, but how exactly would I call this?

I guess the best way would be to call it from :success, but how could
I get the HTML fragment passed by the server then?

Your success function gets passed the response object, so
response.responseText contains whatever the controller generated.
You might find it less hassle to go with Phlip’s suggestion.

Fred

IE has its own proprietary way of modifying table rows and cells (it’s
possible–
Internet Explorer for Developers | Microsoft Learn),
but I don’t think Prototype uses it. Last time I checked it can
successfully remove rows for IE,

-tieg

On May 29, 6:20 am, Firstname Secondname <rails-mailing-l…@andreas-