Reputation: 110950
in index.html.erb, I would like to know how to insert index.js.erb, something like:
<script type="text/javascript">
$(function() {
<%= render =>"home/index.js.erb" %>
});
</script>
Any ideas on how to just insert the index.js.erb file ?
thanks
Upvotes: 4
Views: 2020
Reputation: 11
Set your file as a partial and append preprend or do what you wana do with it.
For a partial file named _index.js.erb located in the same folder of where the file with this code is called will be prepend in the DOMID exemple.
jQuery('#exemple').prepend("<%= escape_javascript(render(:partial => 'index')) %>");
Maybe you can do a html file with it...
<% javascript_tag do %>
<%= render :partial => 'index' %>
or direct code
<% end %>
Upvotes: 1