Monday, 15 June 2015

autocomplete - Disable scrolling through Ajax.Autocompleter suggestion list via '&' and ')' -



autocomplete - Disable scrolling through Ajax.Autocompleter suggestion list via '&' and ')' -

i'm using ajax.autocompleter component, works great - except ampersands in browsers. problem instead of printing ampersand sign search field, acts 'up' arrow in ajax suggestion list. makes users unable write names ampersands search box.

http://github.com/madrobby/scriptaculous/wikis/ajax-autocompleter

specific behavior cases:

if seek type ampersand search field before list suggestions shown, ampersand gets added search field , well.

if seek type ampersand after suggestion list visible, navigate end of list instead, , nil added search field (chrome).

if repeat scenario in ie11, navigate end of list, also add together ampersand search field. however, ajax search not triggered in case - suggestion list remain before nail '&' key, regardless of fact search field not ends &.

firefox adds '&' char search box , refreshes autocomplete suggestion list. expect.

by trial , error, noticed that:

when open f12 in chrome, , debug javascript, ampersand gets printed instead of navigating through suggestion list. when debug off doesn't print , navigates instead. if utilize ctrl+v paste ampersand search field, works fine in browsers. on other hand left alt + 38 things mentioned above, same normal key.

my code:

<input name="searchtxt" id="searchtxt" type="text" autocomplete="off" /> <div id="autocompleteresults" style="display:none;border:1px solid black;background-color:white;text-align:left;"></div> <script type="text/javascript" language="javascript" charset="utf-8"> new ajax.autocompleter('searchtxt','autocompleteresults','someurltogetautocompleteresults', {}); </script>

the clues able find far pretty weak:

someone having vaguely similar ampersand problem in chrome , youtube search https://productforums.google.com/forum/#!topic/chrome/mpt4fkaaqpg another stackoverflow thread regarding ajax.autocompleter, unrelated how create ajax.autocompleter perform request without typing?

any help appreciated - i'll studying ajax.autocompleter project in more detail, since seemed might browser-related, asked hopes might have @ to the lowest degree partial answer.

after more debugging found causing problem. scriptaculous library consists of several .js files - first problem in file 'controls.js', line 129.

here function handles key strokes - instance , downwards arrows navigate through suggestion list. in chrome, function gets called after pressing '&' , '(' keys, instead of arrows, causing issue.

onkeypress: function(event) { if(this.active) switch(event.keycode) { case event.key_tab: case event.key_return: this.selectentry(); event.stop(event); case event.key_esc: this.hide(); this.active = false; event.stop(event); return; case event.key_left: case event.key_right: return; case event.key_up: this.markprevious(); this.render(); event.stop(event); return; case event.key_down: this.marknext(); this.render(); event.stop(event); return; } else if(event.keycode==event.key_tab || event.keycode==event.key_return || (prototype.browser.webkit > 0 && event.keycode == 0)) return; this.changed = true; this.hasfocus = true; if(this.observer) cleartimeout(this.observer); this.observer = settimeout(this.onobserverevent.bind(this), this.options.frequency*1000); }

while still not root cause, it's work , can used @ to the lowest degree workarounds (if chrome ignore arrow keys in function, etc.)

autocomplete

No comments:

Post a Comment