Search the web
Sign In
New User? Sign Up
RubyOnRails · Ruby on Rails
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Hello Everyone   Message List  
Reply | Forward Message #17 of 107 |
AJAX Effects when Adding/Removing table rows

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]







Mon Jan 23, 2006 4:19 pm

jnetsurfer
Offline Offline
Send Email Send Email

Forward
Message #17 of 107 |
Expand Messages Author Sort by Date

Hello Everyone. I recently decided to learn Ruby on Rains and love it so far. Like another member on this list, RE, I am a PHP developer, however unlike RE I...
jnetsurfer
Offline Send Email
Jan 20, 2006
11:51 pm

Ruby / Ruby on Rails Jobs Yahoo Group http://groups.yahoo.com/group/rubyrails -- No virus found in this outgoing message. Checked by AVG Free Edition. Version:...
Beau Gould
techdude27
Offline Send Email
Jan 21, 2006
6:31 am

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...
Joshua Gitlin
jnetsurfer
Offline Send Email
Jan 23, 2006
7:14 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help