<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: AutoComplete.js update 1.2</title>
	<atom:link href="http://www.beauscott.com/2008/06/05/autocompletejs-update-12/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.beauscott.com/2008/06/05/autocompletejs-update-12/</link>
	<description>AJAX, Flex and other RIA</description>
	<lastBuildDate>Thu, 11 Aug 2011 20:53:27 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: Daniella</title>
		<link>http://www.beauscott.com/2008/06/05/autocompletejs-update-12/#comment-59237</link>
		<dc:creator>Daniella</dc:creator>
		<pubDate>Thu, 11 Aug 2011 20:53:27 +0000</pubDate>
		<guid isPermaLink="false">http://www.beauscott.com/2008/06/05/autocompletejs-update-12/#comment-59237</guid>
		<description>This Auto-Complete script is great. Here are two custom features I put in that might be helpful to others:

1- To avoid having an empty drop down box appear when I return an empty set of matches, I return the word &#039;hide&#039; and then I test for this word in the script. On line 481 in version 1.2, you can add an extra line that tests to see if the word &#039;hide&#039; has been returned as the matching text. If it has, the function returns right away instead of displaying the drop down. You should be able to replicate this with returning xml or json instead of text, and you should be able to use any other word aside from hide.
...
/**
	 * Parses the TEXT result, adds options
	 * @param {String} text The text response to parse
	 */
	_parseText: function(text)
	{
		//custom changes to script 
		// don&#039;t display an empty dropdown; just return if the word &#039;hide&#039; is returned by the ajax request
		if(text===&#039;hide&#039;){return;}
		//end changes
		var suggestions = (text&#124;&#124;&quot;&quot;).split(/\n/);
		for(i = 0; i &lt; suggestions.length; i++)
			this._addOption(suggestions[i]);
	},
...

2 - Wanting the behavior where pressing the backspace or delete keys don&#039;t cause the drop down list of suggestions to disappear, I commented that in lines 331 to line 335, in the _suggest function.
It looks like this now:
...
switch(key)
		{
			case Event.KEY_LEFT:
			case Event.KEY_RIGHT:
				return false;
				break;
			case Event.KEY_TAB:
			//case Event.KEY_BACKSPACE:
			//case 46: //Delete
			//	this.cancel();
			//	return false;
			//	break;
			case Event.KEY_RETURN:
				if(this.visible)
...

I hope this is helpful to someone.
Thanks for the script!</description>
		<content:encoded><![CDATA[<p>This Auto-Complete script is great. Here are two custom features I put in that might be helpful to others:</p>
<p>1- To avoid having an empty drop down box appear when I return an empty set of matches, I return the word &#8216;hide&#8217; and then I test for this word in the script. On line 481 in version 1.2, you can add an extra line that tests to see if the word &#8216;hide&#8217; has been returned as the matching text. If it has, the function returns right away instead of displaying the drop down. You should be able to replicate this with returning xml or json instead of text, and you should be able to use any other word aside from hide.<br />
&#8230;<br />
/**<br />
	 * Parses the TEXT result, adds options<br />
	 * @param {String} text The text response to parse<br />
	 */<br />
	_parseText: function(text)<br />
	{<br />
		//custom changes to script<br />
		// don&#8217;t display an empty dropdown; just return if the word &#8216;hide&#8217; is returned by the ajax request<br />
		if(text===&#8217;hide&#8217;){return;}<br />
		//end changes<br />
		var suggestions = (text||&#8221;").split(/\n/);<br />
		for(i = 0; i &lt; suggestions.length; i++)<br />
			this._addOption(suggestions[i]);<br />
	},<br />
&#8230;</p>
<p>2 &#8211; Wanting the behavior where pressing the backspace or delete keys don&#039;t cause the drop down list of suggestions to disappear, I commented that in lines 331 to line 335, in the _suggest function.<br />
It looks like this now:<br />
&#8230;<br />
switch(key)<br />
		{<br />
			case Event.KEY_LEFT:<br />
			case Event.KEY_RIGHT:<br />
				return false;<br />
				break;<br />
			case Event.KEY_TAB:<br />
			//case Event.KEY_BACKSPACE:<br />
			//case 46: //Delete<br />
			//	this.cancel();<br />
			//	return false;<br />
			//	break;<br />
			case Event.KEY_RETURN:<br />
				if(this.visible)<br />
&#8230;</p>
<p>I hope this is helpful to someone.<br />
Thanks for the script!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Scott</title>
		<link>http://www.beauscott.com/2008/06/05/autocompletejs-update-12/#comment-57545</link>
		<dc:creator>Scott</dc:creator>
		<pubDate>Wed, 23 Mar 2011 14:27:39 +0000</pubDate>
		<guid isPermaLink="false">http://www.beauscott.com/2008/06/05/autocompletejs-update-12/#comment-57545</guid>
		<description>I&#039;m not sure if you are still checking this, but I was wondering if it&#039;s possible to pass a hidden &quot;id&quot; value when the user selects the appropriate text value.

If it&#039;s easier, feel free to email me at the address I used for this comment.

Thanks!</description>
		<content:encoded><![CDATA[<p>I&#8217;m not sure if you are still checking this, but I was wondering if it&#8217;s possible to pass a hidden &#8220;id&#8221; value when the user selects the appropriate text value.</p>
<p>If it&#8217;s easier, feel free to email me at the address I used for this comment.</p>
<p>Thanks!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Beau</title>
		<link>http://www.beauscott.com/2008/06/05/autocompletejs-update-12/#comment-57463</link>
		<dc:creator>Beau</dc:creator>
		<pubDate>Thu, 17 Feb 2011 00:36:55 +0000</pubDate>
		<guid isPermaLink="false">http://www.beauscott.com/2008/06/05/autocompletejs-update-12/#comment-57463</guid>
		<description>Thanks, will update.</description>
		<content:encoded><![CDATA[<p>Thanks, will update.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kurt</title>
		<link>http://www.beauscott.com/2008/06/05/autocompletejs-update-12/#comment-57287</link>
		<dc:creator>kurt</dc:creator>
		<pubDate>Wed, 29 Dec 2010 10:08:43 +0000</pubDate>
		<guid isPermaLink="false">http://www.beauscott.com/2008/06/05/autocompletejs-update-12/#comment-57287</guid>
		<description>did you find out how i can add an id to an option ?</description>
		<content:encoded><![CDATA[<p>did you find out how i can add an id to an option ?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stefan Rieger</title>
		<link>http://www.beauscott.com/2008/06/05/autocompletejs-update-12/#comment-57194</link>
		<dc:creator>Stefan Rieger</dc:creator>
		<pubDate>Sat, 13 Nov 2010 13:35:31 +0000</pubDate>
		<guid isPermaLink="false">http://www.beauscott.com/2008/06/05/autocompletejs-update-12/#comment-57194</guid>
		<description>&lt;code&gt;	
/**
	 * @param {Object} input ID of form element, or dom element,  to _suggest on
	 * @param {String} URL of dictionary
	 * @param {Object} options
	 */
	initialize: function(input, action, options)
	{
...
		//this.selector = document.createElement(&#039;select&#039;);
		this.selector = new Element(&#039;select&#039;);
...
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p><code><br />
/**<br />
	 * @param {Object} input ID of form element, or dom element,  to _suggest on<br />
	 * @param {String} URL of dictionary<br />
	 * @param {Object} options<br />
	 */<br />
	initialize: function(input, action, options)<br />
	{<br />
...<br />
		//this.selector = document.createElement('select');<br />
		this.selector = new Element('select');<br />
...<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stefan Rieger</title>
		<link>http://www.beauscott.com/2008/06/05/autocompletejs-update-12/#comment-57193</link>
		<dc:creator>Stefan Rieger</dc:creator>
		<pubDate>Sat, 13 Nov 2010 13:30:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.beauscott.com/2008/06/05/autocompletejs-update-12/#comment-57193</guid>
		<description>Prototype 1.7_rc3 fix
&lt;code&gt;
	/**
	 * Lays the UI elements of the control out, sets interaction options
	 * @param {Object} event Event
	 */
	draw: function()
	{
		if(this.drawn) return;
		if(this.options.cssClass)
			this.selector.className = this.options.cssClass;
    this.input_layout = this.input.getLayout();
    this.selector.absolutize();
    this.selector.setStyle({
      display: &#039;none&#039;,
      height: &#039;auto&#039;,
      width: this.input_layout.get(&#039;width&#039;) + &#039;px&#039;
    });

    this.selector.size = this.options.size;

		document.body.appendChild(this.selector);
		this.input.autocomplete = &#039;off&#039;;
		this.drawn = true;
	},
&lt;/code&gt;

&lt;code&gt;
	/**
	 * Repositions the selector (if visible) to match the new
	 * coords of the input.
	 * @private
	 */
	_reposition: function()
	{
		if(!this.drawn) return;
    var pos = this.input.viewportOffset();
    var pos_scroll = this.input.cumulativeScrollOffset()
		Element.setStyle(this.selector,{
			left: (pos.left + pos_scroll.left ) + &#039;px&#039;,
			top: (pos.top + pos_scroll.top + this.input_layout.get(&#039;border-box-height&#039;)) + &#039;px&#039;
		});
	},
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>Prototype 1.7_rc3 fix<br />
<code><br />
	/**<br />
	 * Lays the UI elements of the control out, sets interaction options<br />
	 * @param {Object} event Event<br />
	 */<br />
	draw: function()<br />
	{<br />
		if(this.drawn) return;<br />
		if(this.options.cssClass)<br />
			this.selector.className = this.options.cssClass;<br />
    this.input_layout = this.input.getLayout();<br />
    this.selector.absolutize();<br />
    this.selector.setStyle({<br />
      display: 'none',<br />
      height: 'auto',<br />
      width: this.input_layout.get('width') + 'px'<br />
    });</p>
<p>    this.selector.size = this.options.size;</p>
<p>		document.body.appendChild(this.selector);<br />
		this.input.autocomplete = 'off';<br />
		this.drawn = true;<br />
	},<br />
</code></p>
<p><code><br />
	/**<br />
	 * Repositions the selector (if visible) to match the new<br />
	 * coords of the input.<br />
	 * @private<br />
	 */<br />
	_reposition: function()<br />
	{<br />
		if(!this.drawn) return;<br />
    var pos = this.input.viewportOffset();<br />
    var pos_scroll = this.input.cumulativeScrollOffset()<br />
		Element.setStyle(this.selector,{<br />
			left: (pos.left + pos_scroll.left ) + 'px',<br />
			top: (pos.top + pos_scroll.top + this.input_layout.get('border-box-height')) + 'px'<br />
		});<br />
	},<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: k3mist</title>
		<link>http://www.beauscott.com/2008/06/05/autocompletejs-update-12/#comment-51882</link>
		<dc:creator>k3mist</dc:creator>
		<pubDate>Thu, 11 Mar 2010 19:13:24 +0000</pubDate>
		<guid isPermaLink="false">http://www.beauscott.com/2008/06/05/autocompletejs-update-12/#comment-51882</guid>
		<description>It doesn&#039;t look like that patch displayed correctly at all. Sorry.</description>
		<content:encoded><![CDATA[<p>It doesn&#8217;t look like that patch displayed correctly at all. Sorry.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: k3mist</title>
		<link>http://www.beauscott.com/2008/06/05/autocompletejs-update-12/#comment-51881</link>
		<dc:creator>k3mist</dc:creator>
		<pubDate>Thu, 11 Mar 2010 19:02:26 +0000</pubDate>
		<guid isPermaLink="false">http://www.beauscott.com/2008/06/05/autocompletejs-update-12/#comment-51881</guid>
		<description>When hitting the tab key with a highlighted selection in the drop-down, the script behaved unpredictably in any browser I tested in. Sometimes it would tab out of the input, sometimes it would not, sometimes the drop-down would not disappear. 

No matter what, when hitting tab, it never placed the highlighted selection into the input box. Maybe this last thing I mentioned was intended. 

Anyway, because of the behavior, it is quite annoying and the best fix I could come up with was making the tab key behave like the enter key.

&lt;code&gt;
From 742bd90a8f27df25338c1552fc2bd5ba80abce09 Mon Sep 17 00:00:00 2001
From: x 
Date: Thu, 11 Mar 2010 13:55:09 -0500
Subject: [PATCH] Make tab key behave like return/enter key in autocomplete lib

---
 js/lib/autocomplete.js &#124;    7        
 1 files changed, 7 insertions( ), 0 deletions(-)

diff --git a/js/lib/autocomplete.js b/js/lib/autocomplete.js
index 223ec02..99c8418 100644
--- a/js/lib/autocomplete.js
    b/js/lib/autocomplete.js
@@ -328,6  328,13 @@ var AutoComplete = Class.create({
 				return false;
 				break;
 			case Event.KEY_TAB:
 				if(this.visible)
 				{
 					this.select();
 					return true;
 				}
 				return false;
 				break;
 			case Event.KEY_BACKSPACE:
 			case 46: //Delete
 				this.cancel();
-- 
1.6.3.3
&lt;/code&gt;</description>
		<content:encoded><![CDATA[<p>When hitting the tab key with a highlighted selection in the drop-down, the script behaved unpredictably in any browser I tested in. Sometimes it would tab out of the input, sometimes it would not, sometimes the drop-down would not disappear. </p>
<p>No matter what, when hitting tab, it never placed the highlighted selection into the input box. Maybe this last thing I mentioned was intended. </p>
<p>Anyway, because of the behavior, it is quite annoying and the best fix I could come up with was making the tab key behave like the enter key.</p>
<p><code><br />
From 742bd90a8f27df25338c1552fc2bd5ba80abce09 Mon Sep 17 00:00:00 2001<br />
From: x<br />
Date: Thu, 11 Mar 2010 13:55:09 -0500<br />
Subject: [PATCH] Make tab key behave like return/enter key in autocomplete lib</p>
<p>---<br />
 js/lib/autocomplete.js |    7<br />
 1 files changed, 7 insertions( ), 0 deletions(-)</p>
<p>diff --git a/js/lib/autocomplete.js b/js/lib/autocomplete.js<br />
index 223ec02..99c8418 100644<br />
--- a/js/lib/autocomplete.js<br />
    b/js/lib/autocomplete.js<br />
@@ -328,6  328,13 @@ var AutoComplete = Class.create({<br />
 				return false;<br />
 				break;<br />
 			case Event.KEY_TAB:<br />
 				if(this.visible)<br />
 				{<br />
 					this.select();<br />
 					return true;<br />
 				}<br />
 				return false;<br />
 				break;<br />
 			case Event.KEY_BACKSPACE:<br />
 			case 46: //Delete<br />
 				this.cancel();<br />
--<br />
1.6.3.3<br />
</code></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Duncan Bradley</title>
		<link>http://www.beauscott.com/2008/06/05/autocompletejs-update-12/#comment-50461</link>
		<dc:creator>Duncan Bradley</dc:creator>
		<pubDate>Wed, 03 Feb 2010 15:16:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.beauscott.com/2008/06/05/autocompletejs-update-12/#comment-50461</guid>
		<description>@Fernando 

I too had the same issue.....looking through prototype&#039;s documentation, there is a viewportOffset() function which seems to provide the answer......
So I changed the _reposition function to this
	_reposition: function()
	{
		if(!this.drawn) return;
		var pos = this.input.viewportOffset() ; 
                //Position.cumulativeOffset(this.input);
		pos.push(pos[0]   this.input.offsetWidth);
		pos.push(pos[1]   this.input.offsetHeight);
		Element.setStyle(this.selector,{
			left: pos[0]   &#039;px&#039;,
			top: pos[3]   &#039;px&#039;
		});
	}

and this now makes it position the dropdown below the field, regardless of where the div is scrolled to....</description>
		<content:encoded><![CDATA[<p>@Fernando </p>
<p>I too had the same issue&#8230;..looking through prototype&#8217;s documentation, there is a viewportOffset() function which seems to provide the answer&#8230;&#8230;<br />
So I changed the _reposition function to this<br />
	_reposition: function()<br />
	{<br />
		if(!this.drawn) return;<br />
		var pos = this.input.viewportOffset() ;<br />
                //Position.cumulativeOffset(this.input);<br />
		pos.push(pos[0]   this.input.offsetWidth);<br />
		pos.push(pos[1]   this.input.offsetHeight);<br />
		Element.setStyle(this.selector,{<br />
			left: pos[0]   &#8216;px&#8217;,<br />
			top: pos[3]   &#8216;px&#8217;<br />
		});<br />
	}</p>
<p>and this now makes it position the dropdown below the field, regardless of where the div is scrolled to&#8230;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Görög Marci</title>
		<link>http://www.beauscott.com/2008/06/05/autocompletejs-update-12/#comment-49072</link>
		<dc:creator>Görög Marci</dc:creator>
		<pubDate>Fri, 08 Jan 2010 19:20:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.beauscott.com/2008/06/05/autocompletejs-update-12/#comment-49072</guid>
		<description>Thank you Beau,
I find it a very useful script, thank you for sharing this! Very good it gives &quot;onSelect&quot; feature, thank you once again!!
Marci</description>
		<content:encoded><![CDATA[<p>Thank you Beau,<br />
I find it a very useful script, thank you for sharing this! Very good it gives &#8220;onSelect&#8221; feature, thank you once again!!<br />
Marci</p>
]]></content:encoded>
	</item>
</channel>
</rss>

