On Jul 3, 7:39 pm, g <[EMAIL PROTECTED]> wrote:
> I have autocompleter.local set up to pull a list from a database.
> Here is the situation:
>
> -type "a" in the text box. all possible entries are displayed
> correctly.
>
> -select "apple" by highlighting and CLICKING IT WITH THE MOUSE.
>
> -the text box now shows "apple"; which is correct
>
> -delete contents from text box and type "t". all possible entries are
> displayed correctly.
>
> - select "tiger" by highlighting it and PRESSING THE "ENTER" KEY
>
> -instead of "tiger".... "tigeriger" is displayed.
>
> my best guess is that the onClick sets an attribute that the
> Event.KEY_RETURN doesn't like.  I'm not sure if this is case specific
> or a bug that slipped through the cracks. any insight would be
> appreciated.

I think this is similar to the question I posed last week (http://
groups.google.com/group/rubyonrails-spinoffs/browse_thread/thread/
09c53e7b3c59aadd?hl=en), but haven't received any answers on.
Certainly in some cases I get the same result (the characters typed on
the end of a selected entry).

If I understand the code correctly, what happens is that
Autocompleter.Base.onKeypress doesn't do anything with the TAB and
RETURN keys until its 'active' has been set, which only happens once
the set of choices has been retrieved. This means that while it is
still obtaining the choices (by the Ajax request, in my case) TAB and
RETURN are just passed onto the browser for its default behaviour (or
to nested handlers if there are any).

I tried to get round it by adding my own onKeypress, but the DOM event
model does not define the order in which handlers on the same object
will be called. I tried to force it with the 'onCapture' argument of
Event#observe, but eventually discovered that though that's
documented, it's actually been removed (I've raised this as a
documentation bug).

The code at ll 130-56 of controls.js (1.8.0):
    if(this.active)
...
       if(event.keyCode==Event.KEY_TAB ||
event.keyCode==Event.KEY_RETURN ||
         (Prototype.Browser.WebKit > 0 && event.keyCode == 0)) return;

indicates that this is deliberate behaviour, but I don't understand
why.
--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
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