If you have a lot of javascript code, I recommend using partial instead of putting it in lines in a helper method.
<% javascript_tag do %>
<%= render :partial => 'layouts/do_something' %>
<% end %>
function do_something() {
// javascript code goes here
}
You can also add ERB tags in this partial.
Does this answer your question? Perhaps I did not understand this completely.
source
share