Forum: Ruby on Rails Problems with RJS & Ajax

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
16f21a34c01153b92bebe7e113846150?d=identicon&s=25 creemej (Guest)
on 2007-07-26 22:09
(Received via mailing list)
I try to create an "onKeypress" event handler for a form but nothing

I have already studied the reference books on Ajax, but that didn't
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: '+;

2) show.rhtml

<%= observe_form "grid-form",
                 :frequency => 0,
                 :function =>
                 :on => "keypress" %>

this generates this javascript in the page:

<script type="text/javascript">
new Form.Observer('grid-form', 0, function(element, value)
{GridControlTracker.gridEventHandler(element,value)}, 'keypress')

These are the questions that I have:
1. Only the <backspace> 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!
This topic is locked and can not be replied to.