Can I use javascript inside rails helper ?
If yes then how?
I am trying with the javascript tag inside application_helper.rb
javascript_tag "$('#all_records tr').slice(- (<%= no_of_rows_remove %>)).remove();"
but it doesn't working.
can anyone suggest me how to do it?
Your helper function should be like:
def helper_function_name
number_of_rows_to_remove = 10
js = "$('#all_records tr').slice(#{number_of_rows_to_remove}).remove();"
return js.html_safe
end
and in your view:
<%= helper_function_name %>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.