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?
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?
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
Ben M. 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.
b
I’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.