I'm using the following code to get data via JS request on my search page
<%= link_to 'All', '/search?type=all', id: 'active', remote: true %>
<%= link_to 'Photographers', '/search?type=photographers', remote: true %>
It's all working fine and I'm getting data as expected. But when I click some other link and then hit back button (provided by browser) it's showing me the JS request data on a blank page instead of going back to search page.
Is there any workaround or fix to this?
in routes.rb
resources :search, only: [:index]
in search controller
def index
// search processing
respond_to do |format|
format.html
format.js
end
end
search/index.js.erb
$('#search-area').html("<%= j render partial: 'search_area' %>");
I'm using Rails 5.0 with Puma