registers an event handler (onclick) on a particular field in one of my
views and then calls a function to do some processing.
Where should I place the event handler and function code? In
application.js? Or in the layout that gets rendered with the view?
Kind of depends on where that view gets called from. If it’s just in
spot or if it’s a partial that gets included all over.
Also depends on whether your event handler is generic enough that it
be reused elsewhere.
Assuming it’s one view and quite specific, I would put the code in:
(replacing controller_name and action_name with the right values)
Then include that in your view…
The nice thing about this is that it makes it (somewhat) easier to see