easiest option:
put the whole table (or table row depending on your needs) into a
partial and then replace the table (or rows) with a new instance of
the partial.
there are various ways to trigger an ajax request - again, this
depends on your needs
checkout:
link_to_remote:
http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html#M001930
observe_field:
http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html#M001939
observe_form:
http://api.rubyonrails.org/classes/ActionView/Helpers/PrototypeHelper.html#M001940
If the controller action deals with more than one format (eg. html and
js) then you should use the respond_to method.
Otherwise,
def my_ajax_action
@content = # new content for your table
replace "id_of_table", render(:partial =>
"partial_name", :locals
=> {:content => @content } )
end
Hope that helps?
Gavin
http://handyrailstips.com
On Jul 6, 2:53 am, JannaB
<mistressja...-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org>
wrote:> I have a view that has a <table> element in it that I want to update
> via ajax, so that the view is not refreshed. The number of rows I have
> will be variable, expanding and contracting, and each row is an
> element in an array of hashes for each cell in the row.
>
> How do you typically do something like this in RoR? All the examples I
> see are for the Scriptaculus kinds of things (autocompete, etc) but
> what about something like this. How would you begin to tackle it?
> Thanks, Janna B