fuliang 发表于 2013-1-29 13:06:00

使用Rails中的Ajax问题

我使用Rails中的Ajax来实现发帖子自动追加到table中,从而不必刷新真个页面的功能,在自己的机子上好
用,在别的机子上试了,需要手工刷新才能看到追加的那行。不知道是为什么?
<table id="posts" class="around">   //other codes...   <%= render(:partial => 'post',:collection => @posts )%></table>   //other codes... <% form_remote_tag(:url => { :action => 'add_post',:topic_id => @topic},                  :update => "posts",                  :position => :bottom ,:before => fckeditor_before_js('post', 'body')) do %>   <%= fckeditor_textarea('post', 'body',         { :toolbarKit => 'Simple', :width => '100%', :height => '400px',:ajax => true }) %>          <p align="center"><%= submit_tag "提交",:id => 'form-submit-button' %></center><% end %>
_post.rhtml
<tr><td width="25%" class="col2"><%=post.user.display_name %><br/>       <img src="/images/photo.gif"/><br/>         上次在(<%= post.user.last_login_at.strftime("%Y-%m-%d %H:%M:%S") %>)到本站一游</td><td width="75%" class="col1"><%= post.body %></td></tr>
页: [1]
查看完整版本: 使用Rails中的Ajax问题