Q:

js.erb template rendered as text

I am trying to make my destroy action work with ajax so I the page dont have to refresh when deleting images..the problem is when I try this with ajax it remove the image but instead it display this text:
<%= j render @category.images

...here is my destroy action : 
def destroy
    @image = @category.images.find(params[:id])
    @image.destroy
  respond_to do |format|
    format.html { redirect_to category_path(@category) }
    format.js
  end
end

destroy.js.erb file:
$('#panel_<%= @image.id %>').html("<%= j render @category.images %>");

and here is where my delete link(i added remote: true as well):
<% @category.images.each do |image| %>
  <div class="col-md-6">

    <div class="panel panel-default panel-show" id= "panel_<%= image.id %>">
        <div class="panel-body panel-body-show">
                <%= image_tag(image.photo.url(:thumb), class: "img-in img-responsive") %>
                <%= link_to "delete", category_image_path(@category, image), remote: true, method: :delete, data: {confirm: "Are you sure?"} %>                       <%= link_to "edit", edit_category_image_path(@category, image) %>
                <ul class="imgs-tables">    
                    <li><h2><%= image.i_name %></h2></li>
                    <hr class="for-title">
                    <li class="second-one"><p><%= image.i_bio %></p></li>
                    <% if image.price %>
                        <li class="price-title"><h3> Price: </h3> </li> <li class="price-li"><h4 class="for-price"><%= image.price %><i class="fa fa-ils"></i></h4></li><br/>
                        <hr class="price-line-up">
                        <hr class="price-line-down">
                    <% end %>
                </ul>
            <ul class="sub-images-show">    
                <% image.sub_images.each do |sub_image| %>
                    <li><%= image_tag(sub_image.small_image.url(:small))  %></li>
                <% end %>
            </ul>
        </div>
    </div>
  </div>
<% end %>

and her is an image that show you what where the text is render

<blockquote class="imgur-embed-pub" lang="en" data-id="a/G9FVD"><a href="//imgur.com/G9FVD"></a></blockquote><script async src="//s.imgur.com/min/embed.js" charset="utf-8"></script>

A:

try this
destroy.js.erb file:
$('#panel_<%= @image.id %>').remove();

