浏览 2167 次
|
锁定老贴子 主题:使用Rails中的Ajax问题
精华帖 (0) :: 良好帖 (0) :: 新手帖 (0) :: 隐藏帖 (0)
|
|
|---|---|
| 作者 | 正文 |
|
时间:2007-05-07
我使用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>
声明:JavaEye文章版权属于作者,受法律保护。没有作者书面许可不得转载。
推荐链接
|
|
| 返回顶楼 | |
|
时间:2007-05-07
发现问题了 我一直用firefox测试的
那段代码在firefox都好使 在IE上不好使 看来Rails对Ajax的封装兼容性上还是有问题的 |
|
| 返回顶楼 | |
|
时间:2007-05-08
fuliang 写道 发现问题了 我一直用firefox测试的
那段代码在firefox都好使 在IE上不好使 看来Rails对Ajax的封装兼容性上还是有问题的 错了,是ff和ie对于table和select两个容器操作的方式不一样,因为他们并不符合prototype对于DOM的抽象,建议你好好看看prototype-api.pdf |
|
| 返回顶楼 | |
|
时间:2007-05-08
你的意思是 table和select他们并不符合prototype对于DOM的抽象,所以向table追加行本来就是不正确的途径,应该把table容器换成
div什么的,表现才能一致。 |
|
| 返回顶楼 | |





