Hi all, I have a table with link_to_remote on each row that changes the status of the object represented by that row. I was wondering if it is possible to use the :update flag to update a <tr>? When I tried it the results just get stuffed into the first column with the rest of the columns blank. Thanks, Andy
Use the link_to to update a div and put the div(''s) around the objects you want to update - regardless of whether they''re TR''s or other. Julian. On 10/09/2005, at 8:03 PM, Andy Shen wrote:> Hi all, > > I have a table with link_to_remote on each row that changes the status > of the object represented by that row. > > I was wondering if it is possible to use the :update flag to update > a <tr>? > When I tried it the results just get stuffed into the first column > with the rest of the columns blank. > > Thanks, > Andy > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On 9/10/05, Julian Leviston <julian-AfxEtdRqmE/tt0EhB6fy4g@public.gmane.org> wrote:> > Use the link_to to update a div and put the div(''s) around the > objects you want to update - regardless of whether they''re TR''s or > other. >I don''t think you can use a div around a TR or TD. At least I''ve never gotten it to work. If there is some trick to make it work I''d like to hear about it. Chris _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
I think that I have come across something similar whaen using Insertion.Bottom(). I think it has something to do with using innerHTML on tables in IE, using document.createElement() worked for me, though it made the code rather more complicated. Ben On 9/10/05, snacktime <snacktime-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On 9/10/05, Julian Leviston <julian-AfxEtdRqmE/tt0EhB6fy4g@public.gmane.org> wrote: > > Use the link_to to update a div and put the div(''s) around the > > objects you want to update - regardless of whether they''re TR''s or > > other. > > > > I don''t think you can use a div around a TR or TD. At least I''ve never > gotten it to work. If there is some trick to make it work I''d like to hear > about it. > > Chris > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >
On 9/10/05, snacktime <snacktime-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 9/10/05, Julian Leviston <julian-AfxEtdRqmE/tt0EhB6fy4g@public.gmane.org> wrote: > > Use the link_to to update a div and put the div(''s) around the > > objects you want to update - regardless of whether they''re TR''s or > > other. > I don''t think you can use a div around a TR or TD. At least I''ve never > gotten it to work. If there is some trick to make it work I''d like to hear > about it.You can put a <tbody> around 1 or more tr elements. -- Chris Griego
snacktime wrote:> I don''t think you can use a div around a TR or TD. At least I''ve never > gotten it to work. If there is some trick to make it work I''d like to hear > about it.You don''t need to use a <div>, just give your element to be updated an ID, and you''re good to go. The update parameter will update any DOM object with the matching ID. From api.rubyonrails.com: link_to_remote(name, options = {}, html_options = {}) Returns a link to a remote action defined by options[:url] (using the url_for format) that’s called in the background using XMLHttpRequest. The result of that request can then be inserted into a DOM object whose id can be specified with options[:update]. This is the same for form_remote_tag etc. In response to the original poster: I would guess that the reason your results are all appearing in the first column is that you forgot to put enough <td> tags and so on into the partial you are rendering with your link_to_remote call. You need to have it generate the HTML for everything inside the <tr> tags you are trying to update, which will include every <td> in that row. If you''re trying to update just one <td>, give that an ID instead and leave the rest of the row as it is. I reckon that should solve it. ~Dave -- Dave Silvester Rent-A-Monkey Website Development Web: http://www.rentamonkey.com/
Thanks all. I''ve resolved the problems I had with the result of the update going into a single cell. The problem was due to my action rendering a partial with a bug in it. It contained the element with the ID that I was updating (in my case the <tr id=>) when it shouldn''t have. And by following http://dev.rubyonrails.com/ticket/2137, now I have a table that contains edit links that changes a row into a form with save links that redisplay the row after the update is saved.