I have a helper function which accepts a table_name parameter and
outputs html. How (and from where) do I call that Rails function from
Javascript (or jQuery)?
Can I call it from jQuery's document.ready?
Or, do I need a .js.erb partial?
Or, am I missing something else completely?
Is it a ruby helper function? If so you can only run it on the server
before rendering the page (or ajax response), so you cannot call it
from javascript. What are you trying to achieve?
Is it a ruby helper function? If so you can only run it on the server
before rendering the page (or ajax response), so you cannot call it
from javascript. What are you trying to achieve?
It's a custom helper function, I defined in a module in app/helpers
(Rails 3 app).
My goal, is to list several table names with spinners after them. Then,
after document.ready fire off AJAX calls to replace the spinners with a
count of all of the records in each table listed.
So, if I understand correctly, you don't want to call the helper from
javascript, you want to fire the AJAX call from javascript and call
the helper from the view rendered by the AJAX action on the server, to
update the appropriate div on the page.
The helper is a ruby file returning html, right? In that case you
just call it from the html.erb file rendered by the AJAX action. js
doesn't come into it.