Re your keyup problem:

Why don't you just bind your submit handler to onsubmit instead of  
onclick?  Then the browser will catch the enter key for you. Your  
input button is already of type submit.


TAG

On Jul 31, 2007, at 6:05 PM, boipster wrote:

>
> My protoype code:
>
> Event.observe(window, 'load', function() {
>     var checkAuth = new Ajax.Updater('uaDiv', '/auth/check', { method:
> 'get' });
>     Event.observe('password', 'keyup', 'catchEnterKey');
> });
>
> the page has the following div in it:
> <div>
>     <label for="loginId">Username</label>
>     <input id="loginId" type="text" name="loginId" value="" />
> </div>
> <div>
>     <label for="password">Password</label>
>     <input id="password" type="password" name="password" value="" />
> </div>
> <div id="uaButtonDiv">
>     <input id="loginButton" type="submit" name="login" value="Login"
> class="uauthLogin" onclick="submitLogin()" />
> </div>
>
> and catchEnterKey looks like this:
>
> function catchEnterKey(e) {
>     if (!e) {
>         e = window.event;
>     }
>     if (e.keyCode == 13) {
>         submitLogin();
>     }
> }
>
> I'm trying to listen to the password input's keyup event and if the
> last key hit was the enter key, I want to call submitLogin().
>
> When I run this in FF the second Event.observe throws and error saying
> element has no properties. Firebug points me to _observeAndCache: on
> line 2239 of protoype.js
>
> If I try to step through this with Firebug I get into _observeAndCache
> and everything is great until line 2241:
> element.addEventListener(name, observer, useCapture); and then it
> throws this error:
>
> [Exception... "Could not convert JavaScript argument" nsresult:
> "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame ::
> http://urlwithheld/prototype.js :: anonymous :: line 2241" data: no]
>
> the Ajax.Updater call preceding loads the login form div (there is no
> actual form). I am using prototype 1.5.0 as that is what came with the
> latest stable script.aculo.us.
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to