`

使用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>
分享到:
评论
3 楼 fuliang 2007-05-08  
你的意思是 table和select他们并不符合prototype对于DOM的抽象,所以向table追加行本来就是不正确的途径,应该把table容器换成
div什么的,表现才能一致。
2 楼 花花公子 2007-05-08  
fuliang 写道
发现问题了 我一直用firefox测试的
那段代码在firefox都好使 在IE上不好使
看来Rails对Ajax的封装兼容性上还是有问题的

错了,是ff和ie对于table和select两个容器操作的方式不一样,因为他们并不符合prototype对于DOM的抽象,建议你好好看看prototype-api.pdf
1 楼 fuliang 2007-05-07  
发现问题了 我一直用firefox测试的
那段代码在firefox都好使 在IE上不好使
看来Rails对Ajax的封装兼容性上还是有问题的

相关推荐

Global site tag (gtag.js) - Google Analytics