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:
- application.js
var GridControlTracker = {}
GridControlTracker = {
gridEventHandler: function(element, value) {
alert('Key Pressed / element: '+ element.id);
}
}
- 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:
- Only the and new input-characters are triggered.
But I would like to trigger the navigation buttons (left, right,
up, down, home …) - I can’t find the way to work with the event object. It must be
instantiated, but how can I work with it? - 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!