My goal is to call a html.erb and a js.erb file with the same controller but it does only call my html file.
My js is not called.
controller/categories_controller.rb
def index
respond_to do |format|
format.html
format.js
end
@categories = Category.order('name ASC')
@category = params[:category]
end
view/categories/index.html.erb
<% @categories.each do |c| %>
<%= link_to c.name, show_category_path(category: c.id), :id => "btn-filter#{c.id}" %>
<% end %>
views/categories/index.js.erb (The problem is here, this file is not called)
alert("test");
$("#btn-filter<%=@category%>").attr("class","active");