# Problems with RJS & Ajax

**URL:** <https://www.ruby-forum.com/t/problems-with-rjs-ajax/110501>\
**Category:** Rails\
**Created:** [July 26, 2007, 10:09pm UTC](https://www.ruby-forum.com/t/problems-with-rjs-ajax/110501 "2007-07-26T22:09:24Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![creemej](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/45deac/32.png) [@creemej](https://www.ruby-forum.com/u/creemej)\
**Post date:** [July 26, 2007, 10:09pm UTC](https://www.ruby-forum.com/t/problems-with-rjs-ajax/110501/1 "2007-07-26T22:09:24Z")

</div>

I try to create an “onKeypress” event handler for a form but nothing  
works!

I have already studied the reference books on Ajax, but that didn’t  
help.  
Can someone explain me how todo this?

These are the code-snippets:

1. application.js

var GridControlTracker = {}  
GridControlTracker = {  
gridEventHandler: function(element, value) {  
alert('Key Pressed / element: '+ element.id);  
}  
}

1. show.rhtml

\<%= observe\_form “grid-form”,  
:frequency =\> 0,  
:function =\>  
“GridControlTracker.gridEventHandler(element,value)”,  
:on =\> “keypress” %\>

this generates this javascript in the page:

These are the questions that I have:

1. Only the and new input-characters are triggered.  
But I would like to trigger the navigation buttons (left, right,  
up, down, home …)
2. I can’t find the way to work with the event object. It must be  
instantiated, but how can I work with it?
3. I don’t see the usage of observe\_form with the function option  
(instead of URL) in code examples. Is this the correct way? I want  
to filter the events that I want to handle and than go to the server  
for the selected events. Is this the only way to do this?

thanks and sjamayee!
