RJS - Insert at top of table?

Quick question regarding RJS and inserting to the top of a table. Here’s
the view I’m working with:

<% for link in @links %> <% end %>
Display title URL Description Category
<%= h link.name %> <%= link_to h(link.url), h(link.url) %> <%=h link.description %> <%=h link.category.name %> <%= link_to 'Edit', :action => 'edit', :id => link %> <%= link_to 'Delete', { :action => 'destroy', :id => link }, :confirm => 'Are you sure?', :post => true %>
and the create.rjs file: if @saved page.insert_html :top, 'links-list', :partial => 'link', :object => @link page.visual_effect :highlight, "link-#{@link.id}" page['link_url'].value = 'http://' page['link_name'].value = '' page['link_description'].value = '' else # not saved, so send back the error messages and new form end

…My question is, how can I insert the new link partial (a table row)
below the row containing the

's in my view? As is, the new link row
is inserted before the table headers and not below. One more quickie, is
there any way to specify the title attribute of a link when using
link_to?? Thanks.

Greg

Greg wrote:

Quick question regarding RJS and inserting to the top of a table.

Quick answer. Don’t. Check the DHTML section of MSDN to find out why.
In
a nutshell, tables are ‘special’.

hth,
Bill

Greg wrote:

Quick question regarding RJS and inserting to the top of a table. Here’s
the view I’m working with:

<% for link in @links %> <% end %>
Display title URL Description Category
<%= h link.name %> <%= link_to h(link.url), h(link.url) %> <%=h link.description %> <%=h link.category.name %> <%= link_to 'Edit', :action => 'edit', :id => link %> <%= link_to 'Delete', { :action => 'destroy', :id => link }, :confirm => 'Are you sure?', :post => true %>
and the create.rjs file: if @saved page.insert_html :top, 'links-list', :partial => 'link', :object => @link page.visual_effect :highlight, "link-#{@link.id}" page['link_url'].value = 'http://' page['link_name'].value = '' page['link_description'].value = '' else # not saved, so send back the error messages and new form end

…My question is, how can I insert the new link partial (a table row)
below the row containing the

's in my view? As is, the new link row
is inserted before the table headers and not below. One more quickie, is
there any way to specify the title attribute of a link when using
link_to?? Thanks.

Greg

Greg -

I ran into this same problem today. I was essentially trying to create
tabbed browsing just like the web browser has, and found out it’s not as
simple as just inserting the html into the table. However, if you only
have a set number of new rows you would want to insert, here’s one way
to do it:

then do

if @saved
page.insert_html :top, ‘new_stuff’, :partial => ‘link’, :object => @link
page.show ‘new_stuff’

try insert_html or replace_html, forgot which worked. Anyways, if you
know about how many rows you would want, then you can just hard code
them in there. I found it to be a pain in the ass though. I hate
tables so I used float:left and stylized it to look like a table.

My suggestion: do what you’re doing but get rid of the tables - ew!

-Ben L.

p.s. i’d love to see someone get this working with tables.

Display title URL Description Category

Hi Ben,

Ben L. wrote:

My suggestion: do what you’re doing but get rid of the tables - ew!

Perfect advice. Time to learn a little CSS. It’s really not hard and
there’s a great getting-started resource at http://www.w3schools.com

p.s. i’d love to see someone get this working with tables.

My understanding is that it’s not possible, at least with IE. From the
horse’s mouth (at
http://msdn.microsoft.com/workshop/author/tables/buildtables.asp )
“because
of the specific structure required by tables, the innerText and
innerHTML
properties of the table and tr objects are read-only.”

hth,
Bill

My suggestion: do what you’re doing but get rid of the tables - ew!

Perfect advice. Time to learn a little CSS. It’s really not hard
and there’s a great getting-started resource at http://
www.w3schools.com

I would love to see someone post an example of XHTML-CSS code that is
able to emulate a table’s inherent features:
â?¢ Same row by row structure, e.g.

MyData

â?¢ Aligning and auto-width of columns working on all browsers
â?¢ Same row height for all cells in one row

I’ve tried a few times already, but none of the solutions cope with
multi-column table-like structures well. If someone can provide me
with some code I can use to replace my tables, please do, really
appreciate it!

Best regards

Peter De Berdt

I would love to see someone post an example of XHTML-CSS code that is
able to emulate a table’s inherent features:

You should really steer away from tables to deal with page layout. Even
displaying tabular data is difficult now because of the lack of AXAJ
support in Prototype for updating the table DOM in IE.

However, since I did run into this problem already, I have some
xhtml-css code that emulates what I needed from tables for a certain
project. A working copy of it is here:
http://jimmy.schementi.com/code/html_css/css_table/table_test.html.

Download both the table_test.html and table.css file and let me know if
you make any improvements on it!

~Jimmy

Greg wrote:

Quick question regarding RJS and inserting to the top of a table.

I’m guessing browser support for this will be entirely random, but it
may be worth a go.

According to the HTML 4.01 spec, (
http://www.htmlhelp.com/reference/html40/tables/tbody.html ) a table can
contain a , 1 or more

and a element. Given that,
and given each element can have an id, you should in theory be able to
insert at the top of TBODY, thus skipping THEAD.

A.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs