how would I replace a complete table row including the <tr>...</tr>
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 <tr> and </tr>, but not the <tr> tag itself (required to
change its parameters).
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)
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 => ...
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?
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.
IE has its own proprietary way of modifying table rows and cells (it's
possible-- Internet Explorer for Developers | Microsoft Docs),
but I don't think Prototype uses it. Last time I checked it can
successfully remove rows for IE,