bram.vandersype-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Jan-03 00:39 UTC
Bug on Form.Observer
I was trying something in Prototype (i''m brand new to it) and mucked up this: document.observe(''dom:loaded'', function() { new Form.Observer(''frmLogin'', 0.3, function() { if($F(''txtEmail'') != '''' && $F(''txtPassword'') != '''') { $(''submLogin'').enable(); } else { $(''submLogin'').disable(); } }); }); now when trying it out live: i got following error in Firebug: [Exception... "''Geen toestemming om eigenschap XULElement.selectedIndex te wijzigen'' when calling method: [nsIAutoCompletePopup::selectedIndex]" nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: "JS frame :: http://localhost/libs/js/prototype.js :: anonymous :: line 3517" data: no] It''s dutch but translates as Exception... "No permission to edit property XULElement...... when calling method: " Form.EventObserver works great, but it''s a login field, so I''d want to be able to press enter from the password field, instead of first blurring the password field... --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
bram.vandersype-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Jan-03 10:42 UTC
Re: Bug on Form.Observer
Okay, I found out (thank you google) that the bug had something to do with Firefox''s Autocomplete function. By adding autocomplete="off" in the <input> field the bug is fixed. However, the input field is still blurred approx every 0.3 seconds (the interval I set I''m guessing) and indeed, when I remove the code from the Form.Observer code, it doesn''t blur anymore. I''m guessing it''s got something to do with how I''m checking against empty fields??? Any help would be great, thanks. On Jan 3, 1:39 am, "bram.vanders...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <bram.vanders...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I was trying something in Prototype (i''m brand new to it) and mucked > up this: > document.observe(''dom:loaded'', function() { > new Form.Observer(''frmLogin'', 0.3, function() { > if($F(''txtEmail'') != '''' && $F(''txtPassword'') != '''') { > $(''submLogin'').enable(); > } else { > $(''submLogin'').disable(); > } > }); > > }); > > now when trying it out live: i got following error in Firebug: > [Exception... "''Geen toestemming om eigenschap > XULElement.selectedIndex te wijzigen'' when calling method: > [nsIAutoCompletePopup::selectedIndex]" nsresult: "0x8057001e > (NS_ERROR_XPC_JS_THREW_STRING)" location: "JS frame ::http://localhost/libs/js/prototype.js:: anonymous :: line 3517" data: > no] > > It''s dutch but translates as Exception... "No permission to edit > property XULElement...... when calling method: " > > Form.EventObserver works great, but it''s a login field, so I''d want to > be able to press enter from the password field, instead of first > blurring the password field...--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
bram.vandersype-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Jan-03 10:51 UTC
Re: Bug on Form.Observer
Issue is solved. The script disabled the button (wether it was allready disabled or not), but this also causes to blur any field you were in/on... Issue solved with: document.observe(''dom:loaded'', function() { new Form.Observer($(''frmLogin''), 0.3, function() { if($F(''txtEmail'') != '''' && $F(''txtPassword'') != '''') { $(''submLogin'').enable(); } else if(!$(''submLogin'').hasAttribute(''disabled'')) { $(''submLogin'').disable(); if($F(''txtEmail'') == '''') { $(''txtEmail'').focus(); } else { $(''txtPassword'').focus(); } } }); }); The last if makes sure the empty field is focussed again, else you could go back in browser history when holding backspace for example. Also, autocomplete="off" could be removed now. On Jan 3, 11:42 am, "bram.vanders...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" <bram.vanders...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Okay, I found out (thank you google) that the bug had something to do > with Firefox''s Autocomplete function. By adding autocomplete="off" in > the <input> field the bug is fixed. However, the input field is still > blurred approx every 0.3 seconds (the interval I set I''m guessing) and > indeed, when I remove the code from the Form.Observer code, it doesn''t > blur anymore. > > I''m guessing it''s got something to do with how I''m checking against > empty fields??? > > Any help would be great, thanks. > > On Jan 3, 1:39 am, "bram.vanders...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org" > > <bram.vanders...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > I was trying something in Prototype (i''m brand new to it) and mucked > > up this: > > document.observe(''dom:loaded'', function() { > > new Form.Observer(''frmLogin'', 0.3, function() { > > if($F(''txtEmail'') != '''' && $F(''txtPassword'') != '''') { > > $(''submLogin'').enable(); > > } else { > > $(''submLogin'').disable(); > > } > > }); > > > }); > > > now when trying it out live: i got following error in Firebug: > > [Exception... "''Geen toestemming om eigenschap > > XULElement.selectedIndex te wijzigen'' when calling method: > > [nsIAutoCompletePopup::selectedIndex]" nsresult: "0x8057001e > > (NS_ERROR_XPC_JS_THREW_STRING)" location: "JS frame ::http://localhost/libs/js/prototype.js::anonymous :: line 3517" data: > > no] > > > It''s dutch but translates as Exception... "No permission to edit > > property XULElement...... when calling method: " > > > Form.EventObserver works great, but it''s a login field, so I''d want to > > be able to press enter from the password field, instead of first > > blurring the password field...--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---