Urkman wrote:> Hello,
>
> I like to use parameters using Event.Observer.
> I want to send the event itself and some parameters to the handler
> function.
> Is there a way to do this?
> Here''s my code. Unfortunately it doesn''t work.
> Can anyone help me?
>
> <html>
> <head>
>   <title>Observer-Test</title>
>   <script src="lib/prototype.js"
type="text/javascript"></script>
>   <script>
>     function getKeyCode(event) {
>        event = event || window.event;
>        return event.keyCode;
>     }
>
>     function myKeyPress(event, Param1, Param2, Param3) {
>       var charCode  = getKeyCode(event);
>       alert(charCode + ''Param1: '' + Param1);
>     	return false;
>     }
>
>     Event.observe(window, ''load'', function() {
>     	Event.observe(myInputField, ''keyup'', new
Function(''fx'',
> ''myKeyPress(event,
"Test1","Test2","Test3")''));
>     });
>   </script>
> </head>
> <body>
>   <input type="text" id="myInputField"
value="" size="25"
> maxlength="255">
> </body>
> </html>
>
> Bye
> Frank
>   
You need Function#bindAsEventListener - see 
http://prototypejs.org/api/function/bindAsEventListener
- Ken Snyder
function myKeyPress(event, Param1, Param2, Param3) {
  var charCode  = event.keyCode;
  alert(charCode + ''Param1: '' + Param1);
  return false;
}
Event.observe(window, ''load'', function() {
  $(''myInputField'').observe(''keyup'',
    myKeyPress.bindAsEventListener(null,
"Test1","Test2","Test3"));
});
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---