jant jquery.prepend html with image_tag

时间:2011-11-02 23:32:18

标签: jquery ruby-on-rails ruby ruby-on-rails-3.1 paperclip

我在创建动作上使用ajax。它工作正常,直到我将image_tag添加到我想要添加的块中。它只在我刷新页面时添加(我使用的是回形针)。

创建动作有jQuery代码(它工作正常)

document.getElementById('text_area').value = '';
$('#table').prepend('<%= escape_javascript(render(@post)) %>');
$('#table  td:first').hide().fadeIn(1500);

并且我想要添加html(没有图像标记(第4行)正常工作)

= content_tag_for(:tr, post) do
  %td.post
    .post_image.fl_l
      =image_tag @user.avatar.url(:thumb),{:style=>" vertical-align:middle;"}
    .post_content.fl_r
      = link_to User.find(post.user_from).name, User.find(post.user_from)
      .wall_post_text{:id => "trun#{post.id}"}
        =truncate(post.body,:length => 150)
        -if post.body.length>150
          .show_and_hide{:id =>"show#{post.id}"}
            = link_to "Show",{:controller => "posts", :action => "show_content", :id => post.id },:remote=>true

      .wall_post_text{:id=>"not_trun#{post.id}" ,:style=>"display:none;"}
        =post.body
        .show_and_hide{:id =>"hide#{post.id}",:style=>"display:none" }
          = link_to "Hide",{:controller => "posts", :action => "hide_content", :id => post.id,},:remote=>true


      .shadow.fl_l
        Posted
        = time_ago_in_words(post.created_at)
        ago
      %b.fl_r
        - if current_user == (post.user) || current_user == User.find(post.user_from)
          = link_to "Delete", post, :method => :delete,
                                     :title => post.body ,
                                     :remote => true

使用jQuery有什么特别的方法吗?或者我做错了什么?

提前致谢

0 个答案:

没有答案