我想,當它使用此代碼的第二行發佈到突出新的消息@micropost但我沒有任何成功:如何使新發布的評論選擇器在jquery(與rails)?
$("table.microposts").prepend("<%= escape_javascript(render(:partial => 'shared/feed_item', :object => @micropost)) %>");
$("#table.micropost_<%= @micropost.id %>").effect("highlight", {}, 3000);
$("#new_micropost")[0].reset();
這是飼料項目部分(我嘗試使用div_for功能以確定新的職位...:
<tr> <%= div_for feed_item do %>
<td class="gravatar">
<%= link_to gravatar_for(feed_item.user), feed_item.user %>
</td>
<td class="micropost">
<span class="user">
<%= link_to feed_item.user.name, feed_item.user %>
</span>
<span class="content">
<%= feed_item.content %>
</span>
<span class="timestamp">
Posted <%= time_ago_in_words(feed_item.created_at) %> ago.
</span>
</td>
<% if current_user?(feed_item.user)%>
<td>
<%= link_to "delete", feed_item, :method => :delete,
:confirm => "You sure?",
:title => feed_item.content %>
</td>
<% end %>
<% end %>
</tr>
<% if @feed_items.any? %>
<table class="microposts" summary="Status feed">
<%= render :partial => 'shared/feed_item', :collection => @feed_items %>
</table>
<%= will_paginate @feed_items %>
<% end %>
希望給足夠的細節感謝所有幫助
謝謝,奇怪它沒有工作,但? – WillLA
@will Sentance你有沒有js錯誤?新評論/微博是否添加到頁面? – rubish
對於這兩個版本,新評論/微博確實會添加(不按預期重新加載頁面) – WillLA