Hi, Hopefully a quick example will illustrate what I''m trying to do. <table> <tr> <td>test</td> <td>test</td> </tr> <tr> <td>row 2</td> <td>row 2</td> </tr> <tr> <td>row 3</td> <td>row 3</td> </tr> </table> Using AJAX, I''d like to be able to replace an entire <tr> block, for example to give: <table> <tr> <td>test</td> <td>test</td> </tr> </table> <p>This is dynamic content</p> <table> <tr> <td>row 3</td> <td>row 3</td> </tr> </table> I (wrongly) assumed the solution would just be: <table> <tr> <td>test</td> <td>test</td> </tr> <div id=''mycontent''> <tr> <td>row 2</td> <td>row 2</td> </tr> </div> <tr> <td>row 3</td> <td>row 3</td> </tr> </table> ... then use AJAX to replace the contents of the ''mycontent'' div. Unfortunately when this renders (in Firefox anyway), the div is placed outside of the table (above it), so any content written to the div also appear outside of the table (I confirmed the position of the div by putting a border around it). Perhaps this is to be expected since in standard HTML the div shouldn''t be where it is. So my question is how I can achieve this replacement of the table row Best, Mark --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
1) get a reference to your tr (for example using table.select(''tr:nth-child(4)'').reduce() ) 2) use tr.insert({before: new Element(''tr'').insert(new Element(''td'').update(''hai'')) }); //or variant of insert with innerhtml content from ajax request 3) tr.remove(); On Wed, Jul 2, 2008 at 12:24 PM, kermit <test-Jp3n8lUXroS9FHfhHBbuYA@public.gmane.org> wrote:> > Hi, > > Hopefully a quick example will illustrate what I''m trying to do. > > <table> > <tr> > <td>test</td> > <td>test</td> > </tr> > <tr> > <td>row 2</td> > <td>row 2</td> > </tr> > <tr> > <td>row 3</td> > <td>row 3</td> > </tr> > </table> > > Using AJAX, I''d like to be able to replace an entire <tr> block, for > example to give: > > <table> > <tr> > <td>test</td> > <td>test</td> > </tr> > > </table> > <p>This is dynamic content</p> > <table> > > <tr> > <td>row 3</td> > <td>row 3</td> > </tr> > </table> > > I (wrongly) assumed the solution would just be: > > <table> > <tr> > <td>test</td> > <td>test</td> > </tr> > <div id=''mycontent''> > <tr> > <td>row 2</td> > <td>row 2</td> > </tr> > </div> > <tr> > <td>row 3</td> > <td>row 3</td> > </tr> > </table> > > ... then use AJAX to replace the contents of the ''mycontent'' div. > Unfortunately when this renders (in Firefox anyway), the div is placed > outside of the table (above it), so any content written to the div > also appear outside of the table (I confirmed the position of the div > by putting a border around it). Perhaps this is to be expected since > in standard HTML the div shouldn''t be where it is. > > So my question is how I can achieve this replacement of the table row > > Best, > Mark > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Gareth, I believe #replace should be able to do this just fine. -- kangax On Jul 1, 8:44 pm, "Gareth Evans" <agr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> 1) get a reference to your tr (for example using > table.select(''tr:nth-child(4)'').reduce() ) > 2) use tr.insert({before: new Element(''tr'').insert(new > Element(''td'').update(''hai'')) }); //or variant of insert with innerhtml > content from ajax request > 3) tr.remove(); > > On Wed, Jul 2, 2008 at 12:24 PM, kermit <t...-Jp3n8lUXroS9FHfhHBbuYA@public.gmane.org> wrote: > > > Hi, > > > Hopefully a quick example will illustrate what I''m trying to do. > > > <table> > > <tr> > > <td>test</td> > > <td>test</td> > > </tr> > > <tr> > > <td>row 2</td> > > <td>row 2</td> > > </tr> > > <tr> > > <td>row 3</td> > > <td>row 3</td> > > </tr> > > </table> > > > Using AJAX, I''d like to be able to replace an entire <tr> block, for > > example to give: > > > <table> > > <tr> > > <td>test</td> > > <td>test</td> > > </tr> > > > </table> > > <p>This is dynamic content</p> > > <table> > > > <tr> > > <td>row 3</td> > > <td>row 3</td> > > </tr> > > </table> > > > I (wrongly) assumed the solution would just be: > > > <table> > > <tr> > > <td>test</td> > > <td>test</td> > > </tr> > > <div id=''mycontent''> > > <tr> > > <td>row 2</td> > > <td>row 2</td> > > </tr> > > </div> > > <tr> > > <td>row 3</td> > > <td>row 3</td> > > </tr> > > </table> > > > ... then use AJAX to replace the contents of the ''mycontent'' div. > > Unfortunately when this renders (in Firefox anyway), the div is placed > > outside of the table (above it), so any content written to the div > > also appear outside of the table (I confirmed the position of the div > > by putting a border around it). Perhaps this is to be expected since > > in standard HTML the div shouldn''t be where it is. > > > So my question is how I can achieve this replacement of the table row > > > Best, > > Mark--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
oh yeah, it would. I used remove/insert myself for this pattern but replace would work just as well. On Wed, Jul 2, 2008 at 1:25 PM, kangax <kangax-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Gareth, > I believe #replace should be able to do this just fine. > > -- kangax > > On Jul 1, 8:44 pm, "Gareth Evans" <agr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > 1) get a reference to your tr (for example using > > table.select(''tr:nth-child(4)'').reduce() ) > > 2) use tr.insert({before: new Element(''tr'').insert(new > > Element(''td'').update(''hai'')) }); //or variant of insert with innerhtml > > content from ajax request > > 3) tr.remove(); > > > > On Wed, Jul 2, 2008 at 12:24 PM, kermit <t...-Jp3n8lUXroS9FHfhHBbuYA@public.gmane.org> wrote: > > > > > Hi, > > > > > Hopefully a quick example will illustrate what I''m trying to do. > > > > > <table> > > > <tr> > > > <td>test</td> > > > <td>test</td> > > > </tr> > > > <tr> > > > <td>row 2</td> > > > <td>row 2</td> > > > </tr> > > > <tr> > > > <td>row 3</td> > > > <td>row 3</td> > > > </tr> > > > </table> > > > > > Using AJAX, I''d like to be able to replace an entire <tr> block, for > > > example to give: > > > > > <table> > > > <tr> > > > <td>test</td> > > > <td>test</td> > > > </tr> > > > > > </table> > > > <p>This is dynamic content</p> > > > <table> > > > > > <tr> > > > <td>row 3</td> > > > <td>row 3</td> > > > </tr> > > > </table> > > > > > I (wrongly) assumed the solution would just be: > > > > > <table> > > > <tr> > > > <td>test</td> > > > <td>test</td> > > > </tr> > > > <div id=''mycontent''> > > > <tr> > > > <td>row 2</td> > > > <td>row 2</td> > > > </tr> > > > </div> > > > <tr> > > > <td>row 3</td> > > > <td>row 3</td> > > > </tr> > > > </table> > > > > > ... then use AJAX to replace the contents of the ''mycontent'' div. > > > Unfortunately when this renders (in Firefox anyway), the div is placed > > > outside of the table (above it), so any content written to the div > > > also appear outside of the table (I confirmed the position of the div > > > by putting a border around it). Perhaps this is to be expected since > > > in standard HTML the div shouldn''t be where it is. > > > > > So my question is how I can achieve this replacement of the table row > > > > > Best, > > > Mark > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Jul 2, 10:24 am, kermit <t...-Jp3n8lUXroS9FHfhHBbuYA@public.gmane.org> wrote:> Hi, > > Hopefully a quick example will illustrate what I''m trying to do. >[...]> <table> > <tr> > <td>test</td> > <td>test</td> > </tr> > <div id=''mycontent''>Replace that with a tbody element. -- Rob --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---