> I''d like to include some simple JavaScript in my application that
> 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
one
spot or if it''s a partial that gets included all over.
Also depends on whether your event handler is generic enough that it could
be reused elsewhere.
Assuming it''s one view and quite specific, I would put the code in:
public/javascripts/controller_name/action_name.js
(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
what javascript (or CSS or images) go with what controllers/actions...
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---