Does anyone know how I can implement event handlers in rails? I''m a super newbie to programming in general and wanted to start with a language that is really simple. Besides that, I have a little javascript knowledge. So I was wondering how I could integrate event handlers into my pages? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Auston Bunsen wrote:> Does anyone know how I can implement event handlers in rails? I''m a > super newbie to programming in general and wanted to start with a > language that is really simple. > > Besides that, I have a little javascript knowledge. > > So I was wondering how I could integrate event handlers into my pages?Ok, I figured out how to include event handlers, it''s like this"<%= start_form_tag({:action=>''update'', :id=>@alert}, :onsubmit=>''getComment()'') %>" but now: If I want my event handler to trigger an ajax call that works with an action/method in my rails controller? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Take a look at link_to_remote. It has a hooks for setting javascript callbacks to run while loading, on success, on failure, etc. Then just add the action to handle it on the server side and you''re all set. b Auston Bunsen wrote:> Auston Bunsen wrote: >> Does anyone know how I can implement event handlers in rails? I''m a >> super newbie to programming in general and wanted to start with a >> language that is really simple. >> >> Besides that, I have a little javascript knowledge. >> >> So I was wondering how I could integrate event handlers into my pages? > > Ok, I figured out how to include event handlers, it''s like this"<%= > start_form_tag({:action=>''update'', :id=>@alert}, > :onsubmit=>''getComment()'') %>" but now: > > If I want my event handler to trigger an ajax call that works with an > action/method in my rails controller? >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Ben Munat wrote:> Take a look at link_to_remote. It has a hooks for setting javascript > callbacks to run while loading, on success, on failure, etc. Then just > add the action to handle it on the server side and you''re all set. > > bI''m very sorry. I should have been more specific. I know how to use, an onclick even handler because that comes with rails. but for instance, in a form, i''ll have a select element with 3 options, and if a certain option is selected, it will prompt javascript to have an additional field fade in. I''m guessing hardcoding it will be the easiest. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---