Is there an option to prevent the ''return'' key from autocompleting? On my application I like having the autocomplete show possible matches for users, but I dont want to force them to use a partial match. Example: 1) User wants to enter "sock" into the textbox 2) Autocomplete finds a term "sockpuppet" and shows it 3) User sees "sockpuppet" but is still satisfied with "sock", so he hits return to submit the form --> but "sockpuppet" autofills into the box! The only way to circumvent the autocompletion is to put a space, comma, etc. Thanks, Justin -- Justin Chen Two-Bit Operation LLC http://www.twobitoperation.com _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Have you tried changing the autocomplete tokens? I imagine trapping or not trapping the ''\n'' (newline character ) would control this behavior. Before- tokens: new Array('' '','','',''\n'') After- tokens: new Array('' '','','') On 7/26/06, Justin Chen <justin.h.chen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Is there an option to prevent the ''return'' key from autocompleting? On my > application I like having the autocomplete show possible matches for users, > but I dont want to force them to use a partial match. > > Example: > 1) User wants to enter "sock" into the textbox > 2) Autocomplete finds a term "sockpuppet" and shows it > 3) User sees "sockpuppet" but is still satisfied with "sock", so he hits > return to submit the form --> but "sockpuppet" autofills into the box! The > only way to circumvent the autocompletion is to put a space, comma, etc. > > Thanks, > Justin > > > > -- > Justin Chen > Two-Bit Operation LLC > http://www.twobitoperation.com > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > >-- Thanks, -Steve http://www.stevelongdo.com _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
I tried passing \n as a token but it doesnt seem to do anything with it. My unelegant workaround for now is to comment out the line in controls.js that looks for return: switch(event.keyCode) { case Event.KEY_TAB: // case Event.KEY_RETURN: this.selectEntry(); Event.stop(event); Justin On 7/26/06, Steve Longdo <steve.longdo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Have you tried changing the autocomplete tokens? I imagine trapping or > not trapping the ''\n'' (newline character ) would control this behavior. > > Before- tokens: new Array('' '','','',''\n'') > > After- tokens: new Array('' '','','') > > On 7/26/06, Justin Chen <justin.h.chen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Is there an option to prevent the ''return'' key from autocompleting? On > my application I like having the autocomplete show possible matches for > users, but I dont want to force them to use a partial match. > > Example: > 1) User wants to enter "sock" into the textbox > 2) Autocomplete finds a term "sockpuppet" and shows it > 3) User sees "sockpuppet" but is still satisfied with "sock", so he hits > return to submit the form --> but "sockpuppet" autofills into the box! The > only way to circumvent the autocompletion is to put a space, comma, etc. > > Thanks, > Justin > > > > -- > Justin Chen > Two-Bit Operation LLC > http://www.twobitoperation.com > > _______________________________________________ > Rails-spinoffs mailing list > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs > > > > > > -- > Thanks, > -Steve > http://www.stevelongdo.com >-- Justin Chen Two-Bit Operation LLC http://www.twobitoperation.com _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs
Actually, my last workaround didn''t totally work... What did seem to work was changing the default index to null in updateChoices. This makes it so that nothing is selected by default so enter still submits unless the user actively selects a choice from the selection box. justin On 7/27/06, Justin Chen <justin.h.chen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > I tried passing \n as a token but it doesnt seem to do anything with it. > My unelegant workaround for now is to comment out the line in controls.jsthat looks for return: > > switch(event.keyCode) { > case Event.KEY_TAB: > // case Event.KEY_RETURN: > this.selectEntry(); > Event.stop(event); > > Justin > > > > On 7/26/06, Steve Longdo <steve.longdo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > Have you tried changing the autocomplete tokens? I imagine trapping or > > not trapping the ''\n'' (newline character ) would control this behavior. > > > > Before- tokens: new Array('' '','','',''\n'') > > > > After- tokens: new Array('' '','','') > > > > On 7/26/06, Justin Chen < justin.h.chen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > > Is there an option to prevent the ''return'' key from autocompleting? > > On my application I like having the autocomplete show possible matches for > > users, but I dont want to force them to use a partial match. > > > > Example: > > 1) User wants to enter "sock" into the textbox > > 2) Autocomplete finds a term "sockpuppet" and shows it > > 3) User sees "sockpuppet" but is still satisfied with "sock", so he hits > > return to submit the form --> but "sockpuppet" autofills into the box! The > > only way to circumvent the autocompletion is to put a space, comma, etc. > > > > Thanks, > > Justin > > > > > > > > -- > > Justin Chen > > Two-Bit Operation LLC > > http://www.twobitoperation.com > > > > _______________________________________________ > > Rails-spinoffs mailing list > > Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > > http://lists.rubyonrails.org/mailman/listinfo/ rails-spinoffs<http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs> > > > > > > > > > > > > -- > > Thanks, > > -Steve > > http://www.stevelongdo.com > > > > > > -- > Justin Chen > Two-Bit Operation LLC > http://www.twobitoperation.com >-- Justin Chen Two-Bit Operation LLC http://www.twobitoperation.com _______________________________________________ Rails-spinoffs mailing list Rails-spinoffs-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs