When I step into Event.observe('password', 'keypress',
'catchEnterKey'); it appear that its loosing the eventName
( 'keypress')...
On Aug 1, 10:56 am, boipster <[EMAIL PROTECTED]>
wrote:
> Thank you for your help so far btw, it is appreciated.
>
> On Jul 31, 9:07 pm, Tom Gregory <[EMAIL PROTECTED]> wrote:
>
> > Okay.. that's not the same problem you described before. My advice
> > about using the form's onsubmit handler instead of polling the
> > document for an enter still holds.
>
> > I don't quite understand *why* you're trying to do it the way, you
> > are, but based on what you described this time, attach the keydown
> > observer (your validate function) to the password field, bind your
> > submitLogin function to the form's onsubmit event, and it should work.
>
> > ... and a general piece of advice regarding your original question:
> > if a window observer doesn't work in IE, try observing the document
> > instead. One works for key/mouse events, and the other doesn't. I
> > don't recall which is which.
>
> > TAG
>
> > On Jul 31, 2007, at 7:15 PM, boipster wrote:
>
> > > That would work, however I will eventually be putting validation into
> > > this same catchEnterKey handler. I will be validating before submit
> > > and when the validation passes the button, as well as the enter key
> > > press, will call submitLogin. If validation doesn't pass then the
> > > button will remain disabled and the enter key will not submit. I just
> > > haven't added that code yet. I want to test that I am indeed able to
> > > catch an enter keypress and execute my catchEnterKey function first.
>
> > > To clarify:
> > > on every keypress in the password field I will check validation.
> > > If validation passes
> > > enable login button and allow enter keypress to submit
> > > Else
> > > disable login button, enter key displays error message.
>
> > > Thanks,
>
> > > On Jul 31, 7:42 pm, Tom Gregory <[EMAIL PROTECTED]> wrote:
> > >> 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
-~----------~----~----~----~------~----~------~--~---