Quick question regarding RJS and inserting to the top of a table. Here’s
the view I’m working with:
Display title
URL
Description
Category
<% for link in @links %>
<%= 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 %>
<% end %>
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.
Quick question regarding RJS and inserting to the top of a table. Here’s
the view I’m working with:
Display title
URL
Description
Category
<% for link in @links %>
<%= 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 %>
<% end %>
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:
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.
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 Microsoft Learn: Build skills that open doors in your career )
“because
of the specific structure required by tables, the innerText and
innerHTML
properties of the table and tr objects are read-only.”
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!
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.
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, ( TBODY - Table Body ) 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.