Please Help how to write JQuery coding in Helper function on Rails.
+2
A:
If you have a lot of javascript code then I recommend using a partial instead of trying to place it in strings in a helper method.
<!-- in views/layouts/application.html.erb -->
<% javascript_tag do %>
<%= render :partial => 'layouts/do_something' %>
<% end %>
<!-- in views/layouts/_do_something.js.erb -->
function do_something() {
// javascript code goes here
}
You can add ERB tags in that partial as well.
Does this answer your question? I may not have understood it entirely.
ryanb
2009-08-06 15:14:07