<% if !request.xhr? %> <textarea> <% end %> $('#image_list').append("<%= j render :partial => 'image', :object => @image %>"); $('#imageModal').modal('hide'); $('#ajaxForm').resetForm(); <% if !request.xhr? %> </textarea> <% end %>