I have an app in rails 4 and after doing the scaffolding it generates a * .js.coffee for each template, as I am not yet using coffeescript renamed to * .js and I am trying to use jQuery. The problem is that I need to trigger a process delayed by ajax after loading the page itens/show/x
and did as follows
$(document).ready(function() {
$.ajax({
url:'/get_content_recommendation/' + gon.item_id + '.js',
type:"get"
});
});
The problem is that it is running on all pages of the app, because of <%= javascript_include_tag "application", media: "all" %>
in layout before <%= yield %>
What is the best solution for separating jQuery by view, is there any gem or any good practice? Is this the best way to trigger ajax process after page loading?