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 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 -~----------~----~----~----~------~----~------~--~---
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 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 -~----------~----~----~----~------~----~------~--~---
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 <t...-PGZyUNKar/Q@public.gmane.org> 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 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 -~----------~----~----~----~------~----~------~--~---
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 <t...-PGZyUNKar/Q@public.gmane.org> 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 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 -~----------~----~----~----~------~----~------~--~---
The problem is that I don''t seem to be able to observe the password field. It doesn''t matter what function I''m trying to kick off, I get errors saying the element has no properties or, when stepping through the code with firebug, could not convert Javascript argument. Event.observe(window, ''load'', function() { var checkAuth = new Ajax.Updater(''uaDiv'', ''/auth/check'', { method: ''get'', asynchronous: false }); Event.observe(''password'', ''keypress'', ''catchEnterKey''); }); I tried to make the Ajax.Updater synchronous in case the problem was the form wasn''t fully loaded before the observer call. Now I don''t get the element has no property errors, I just get the following: [Exception... "Could not convert JavaScript argument" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: http://withheld/prototype.js :: anonymous :: line 2241" data: no] This leads me to believe that initially the form wasn''t fully loaded and the password input was not there for addEventListener to use. However now I''m clueless. I haven''t the foggiest what the above error is telling me... On Jul 31, 9:07 pm, Tom Gregory <t...-PGZyUNKar/Q@public.gmane.org> 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 <t...-PGZyUNKar/Q@public.gmane.org> 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 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 -~----------~----~----~----~------~----~------~--~---
Thank you for your help so far btw, it is appreciated. On Jul 31, 9:07 pm, Tom Gregory <t...-PGZyUNKar/Q@public.gmane.org> 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 <t...-PGZyUNKar/Q@public.gmane.org> 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 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 -~----------~----~----~----~------~----~------~--~---
When I step into Event.observe(''password'', ''keypress'', ''catchEnterKey''); it appear that its loosing the eventName ( ''keypress'')... On Aug 1, 10:56 am, boipster <twelvefluidouncesofs...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Thank you for your help so far btw, it is appreciated. > > On Jul 31, 9:07 pm, Tom Gregory <t...-PGZyUNKar/Q@public.gmane.org> 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 <t...-PGZyUNKar/Q@public.gmane.org> 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 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 -~----------~----~----~----~------~----~------~--~---
A handful of comments inline: On Aug 1, 2007, at 9:55 AM, boipster wrote:> The problem is that I don''t seem to be able to observe the password > field. It doesn''t matter what function I''m trying to kick off, I get > errors saying the element has no properties or, when stepping through > the code with firebug, could not convert Javascript argument.I''ve never tried observing a password element. Have you tried building a small proof-of-concept page (with an already existing pw element) to test that it can be done, and isn''t a browser restriction?> Event.observe(window, ''load'', function() { > var checkAuth = new Ajax.Updater(''uaDiv'', ''/auth/check'', { method: > ''get'', asynchronous: false }); > Event.observe(''password'', ''keypress'', ''catchEnterKey''); > });Why are you firing an Ajax.Updater on page load, rather than just loading the correct content the first time? Seems a bit odd.> ... > > This leads me to believe that initially the form wasn''t fully loaded > and the password input was not there for addEventListener to use.That''s a reasonable guess, given the circumstances. Have you tried putting the subsequent Event.observe in a setTimeout? e.x. Event.observe(window, ''load'', function() { var checkAuth = new Ajax.Updater(''uaDiv'', ''/auth/check'', { method: ''get'', asynchronous: false }); setTimeout(function() {Event.observe(''password'', ''keypress'', ''catchEnterKey'');}, 10); }); --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Created a new html document and included this in the head: <script language="JavaScript" type="text/javascript" src "scriptaculous/prototype.js"></script> <script language="JavaScript" type="text/javascript" src "scriptaculous/scriptaculous.js"></script> <script language="JavaScript" type="text/javascript"> <!-- Event.observe(window, ''load'', function() { Event.observe(''loginForm'', ''keyup'', ''catchEnterKey''); }); function catchEnterKey(e) { if (!e) { e = window.event; } if (e.keyCode == 13) { alert(''ok''); } } //--> </script> and this in the body: <form id="loginForm" method="POST" action="javascript: submitLogin"> <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> </form> Got this error: uncaught exception: [Exception... "Could not convert JavaScript argument" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: http://withheld/prototype.js :: anonymous :: line 2241" data: no] --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I uploaded an image (http://groups.google.com/group/rubyonrails- spinoffs/web/errorimage.JPG) of where the problem seems to be happening. Notice in the image that on the script side it says name " " while on the watch side is shows its set. stepping through this code shows that its dropping the eventName parameter. BTW, I just updated to Prototype v 1.5.1 and scriptaculous 1.7.1 beta3. Problem still exists, at least for me. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled</title> <script language="JavaScript" type="text/javascript" src "scriptaculous/prototype.js"></script> <script language="JavaScript" type="text/javascript" src "scriptaculous/scriptaculous.js"></script> <script language="JavaScript" type="text/javascript"> function catchEnterKey(e) { if (!e) { e = window.event; } if (e.keyCode == 13) { alert(''ok''); } } //--> </script> </head> <body> <form id="loginForm" method="POST" action="javascript: submitLogin"> <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" /> </div> </form> <script language="JavaScript" type="text/javascript"> <!-- Event.observe(''loginButton'', ''click'', ''catchEnterKey''); //--> </script> </body> </html> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
the last post still has the problem.... Is there is something wrong with this statement that I am not seeing? Event.observe(''loginButton'', ''click'', ''catchEnterKey''); --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
ok, having the handler function in quotes is the problem. I don''t know why it was effecting the eventName, but when I remove the quotes from catchEnterKey it works... seesh... Thanks again TAG for all your help. On Aug 1, 12:48 pm, boipster <twelvefluidouncesofs...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> the last post still has the problem.... > > Is there is something wrong with this statement that I am not seeing? > > Event.observe(''loginButton'', ''click'', ''catchEnterKey'');--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Gah. I should have seen it. I keep looking for the hard/obscure reasons, not the easy ones. Event.observe (and every other callback option in Prototype) requires a function reference, not a string, so yeah, it''d get you in trouble. Glad it''s working. TAG On Aug 1, 2007, at 1:10 PM, boipster wrote:> > ok, having the handler function in quotes is the problem. I don''t > know why it was effecting the eventName, but when I remove the quotes > from catchEnterKey it works... > > seesh... > > Thanks again TAG for all your help. > > On Aug 1, 12:48 pm, boipster <twelvefluidouncesofs...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: >> the last post still has the problem.... >> >> Is there is something wrong with this statement that I am not seeing? >> >> Event.observe(''loginButton'', ''click'', ''catchEnterKey''); > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I recognized all the posts in here an found in google, but i still cant solve this problem... obj = $(''header_" & i & "''); Event.observe(obj, ''click'', select_container(obj)); Althow the function isn''t written in quotes, i got this error... Fehler: uncaught exception: [Exception... "Could not convert JavaScript argument" nsresult: "0x80570009 (NS_ERROR_XPC_BAD_CONVERT_JS)" location: "JS frame :: http://192.168.101.81/wwwroot/incl/js/prototype.js :: anonymous :: line 2999" data: no] Is there another reason for this error expect the function in strings? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Found the solution by myself: Event.observe(obj, ''click'', function() {select_container(obj);}); instead of: Event.observe(obj, ''click'', select_container(obj)); --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Walter Lee Davis
2007-Aug-07 15:17 UTC
Re: Event.observe() error: element has no properties
I am not sure you can use & as a concatenation operator here -- this looks like VBScript to me. Try using a + instead. Walter On Aug 7, 2007, at 5:23 AM, Valentin wrote:> obj = $(''header_" & i & "'');--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---