Hello Everyone,
I hope you AJAX pros don't mind me asking such a simple question, but
it's been baffling me all weekend. I'm trying to learn the AJAX side
of rails and struggling with what I though would be fairly simple
operations. I'd like to add rows to a table, and use an effect, like
Slide Down or Highlight. However, when I tried to add them in the way
recommended by the book I'm going off of, it didn't work. Here's some
snippits of what I have:
My view:
-------------------------------
<% content_for("page_scripts") do -%>
function item_added()
{
var item = $('mytable').lastChild.lastChild;
new Effect.Highlight(item);
}
<% end -%>
<h1>Listing</h1>
<%= link_to 'New', :action => 'new' %>
<div id="mytable_div">
<table id="mytable">
<%= render(:partial => 'mytable') -%>
</table>
</div>
<br />
-------------------------------
_mytable.rhtml:
-------------------------------
<tr bgcolor="#999999">
<th><font color="#ffffff">Col1</font></th>
<th><font color="#ffffff">Col2</font></th>
<th><font color="#ffffff">Col3</font></th>
<th><font color="#ffffff">...</font></th>
<th><font color="#ffffff">Col9</font></th>
</tr>
<%= render(:partial => 'row', :collection => @items) -%>
-------------------------------
_row.rhtml:
-------------------------------
<tr bgcolor="#dddddd" id="timecard_<%= timecard.id %>">
<td><%=h item.val1 %></td>
<td><%=h item.val2 %></td>
<td><%=h item.val3 %></td>
<td>...</td>
<td><%=h item.val9 %></td>
</tr>
-------------------------------
Controller's new action:
-------------------------------
def new
item = MyClass.new()
render(:partial => 'row', :object => item, :layout => false)
end
The row is added by AJAX but no effect is called... any idea what I'm
doing wrong?
-Josh
-----------
Due to the recent increase in spam and falsely sent email, I now PGP
Sign all of my outgoing mail to prove my identity. This means that
you will see an attachment called "PGP.sig" with this message. This
attachment can be used to prove that I am who I say I am. If you are
not familiar with PGP, you can safely ignore it. For more
information, please visit http://www.pgp.com/ or http://www.gnupg.org/
[Non-text portions of this message have been removed]