<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>jQuery Tutorials &#38; Plugins &#187; AutoComplete</title>
	<atom:link href="http://jqueryblog.net/tag/autocomplete/feed/" rel="self" type="application/rss+xml" />
	<link>http://jqueryblog.net</link>
	<description></description>
	<lastBuildDate>Mon, 05 Jul 2010 08:45:57 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>jQuery AutoComplete Plugin</title>
		<link>http://jqueryblog.net/2009/11/jquery-autocomplete-plugin/</link>
		<comments>http://jqueryblog.net/2009/11/jquery-autocomplete-plugin/#comments</comments>
		<pubDate>Sat, 14 Nov 2009 10:19:14 +0000</pubDate>
		<dc:creator>Osman Erdo&#287;an</dc:creator>
				<category><![CDATA[jQuery Plugin]]></category>
		<category><![CDATA[jQuery Tutorial]]></category>
		<category><![CDATA[AutoComplete]]></category>
		<category><![CDATA[AutoComplete Plugin]]></category>
		<category><![CDATA[Plugin]]></category>

		<guid isPermaLink="false">http://jqueryblog.net/?p=40</guid>
		<description><![CDATA[I&#8217;d like to present another jQuery plugin, this time it&#8217;s autocomplete with some handy features. 
Description

The major benefit offered by this plugin is its high performance. As all request results are cached, the cache might be used next time, which leaves the server alone.
Besides, AutoComplete has some unique features, such as text separators, searching by [...]]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin-left: 10px;"><a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fjqueryblog.net%2F2009%2F11%2Fjquery-autocomplete-plugin%2F"><img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fjqueryblog.net%2F2009%2F11%2Fjquery-autocomplete-plugin%2F" height="61" width="51" /></a></div><p>I&#8217;d like to present another jQuery plugin, this time it&#8217;s autocomplete with some handy features. </p>
<p><strong>Description</strong><br />
<img src="http://jqueryblog.net/wp-content/uploads/2009/11/1.png" alt="1" title="1" width="386" height="149" class="alignnone size-full wp-image-41" /></p>
<p>The major benefit offered by this plugin is its high performance. As all request results are cached, the cache might be used next time, which leaves the server alone.</p>
<p>Besides, AutoComplete has some unique features, such as text separators, searching by a few words, and the optional using of the component autonomously, i.e. without sending requests to the server.</p>
<p>The plugin works in IE 6.0+, FF 2+, Safari 2.0+, Opera 9.0+, and Chrome 1.0+.</p>
<p><img src="http://jqueryblog.net/wp-content/uploads/2009/11/2.png" alt="2" title="2" width="372" height="83" class="alignnone size-full wp-image-42" /></p>
<p><strong>Installation</strong></p>
<p>Installing the plugin is a routine task — just include the .js file after jQuery.</p>
<pre class="brush: xml;">&lt;script type=&quot;text/javascript&quot; src=&quot;jquery.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;jquery.autocomplete.js&quot;&gt;&lt;/script&gt;</pre>
<p><strong>Usage</strong></p>
<p>Let&#8217;s add autocomplete for the standard input:</p>
<pre class="brush: xml;">&lt;input type=&quot;text&quot; name=&quot;q&quot; id=&quot;query&quot; /&gt;</pre>
<p>The autocomplete object is then initialized — make sure that initialization is duly done following the DOM loading, otherwise IE users might experience some glitches.</p>
<pre class="brush: jscript;">jQuery('#query').autocomplete({
        serviceUrl: 'service/autocomplete.ashx', // Page for processing autocomplete requests
        minChars: 2, // Minimum request length for triggering autocomplete
        delimiter: /(,|;)\s*/, // Delimiter for separating requests (a character or regex)
        maxHeight: 400, // Maximum height of the suggestion list, in pixels
        width: 300, // List width
        zIndex: 9999, // List's z-index
        deferRequestBy: 0, // Request delay (milliseconds), if you prefer not to send lots of requests while the user is typing. I usually set the delay at 300 ms.
        params: { country: 'Yes'}, // Additional parameters
        onSelect: function(data, value){ }, // Callback function, triggered if one of the suggested options is selected,
        lookup: ['January', 'February', 'March'] // List of suggestions for local autocomplete
    });</pre>
<p>The page specified in serviceUrl receives a GET request, in response to which it must send JSON data:</p>
<pre class="brush: jscript;">{
    query:'Li', // Original request
    suggestions:['Liberia','Libyan Arab Jamahiriya','Liechtenstein','Lithuania'], // List of suggestions
    data:['LR','LY','LI','LT'] // Optional parameter: list of keys for suggestion options; used in callback functions.
    }</pre>
<p>You can turn autocomplete on/off as well as re-initialize its parameters anytime via the object functions:</p>
<pre class="brush: jscript;">var ac = jQuery('#query').autocomplete({ /*parameters*/ });
    ac.disable();
    ac.enable();
    ac.setOptons({ zIndex: 1001 });</pre>
<p><strong>Stylization</strong></p>
<p>The script makes the following tagged piece of code:</p>
<pre class="brush: xml;">&lt;div class=&quot;autocomplete-w1&quot;&gt;
 &lt;div style=&quot;width:299px;&quot; id=&quot;Autocomplete_1240430421731&quot; class=&quot;autocomplete&quot;&gt;
  &lt;div&gt;&lt;strong&gt;Li&lt;/strong&gt;beria&lt;/div&gt;
  &lt;div&gt;&lt;strong&gt;Li&lt;/strong&gt;byan Arab Jamahiriya&lt;/div&gt;
  &lt;div&gt;&lt;strong&gt;Li&lt;/strong&gt;echtenstein&lt;/div&gt;
  &lt;div class=&quot;selected&quot;&gt;&lt;strong&gt;Li&lt;/strong&gt;thuania&lt;/div&gt;
 &lt;/div&gt;
&lt;/div&gt;</pre>
<p><img src="http://jqueryblog.net/wp-content/uploads/2009/11/2.png" alt="2" title="2" width="372" height="83" class="alignnone size-full wp-image-42" /></p>
<p>Here&#8217;s an example of CSS styles:</p>
<pre class="brush: css;">.autocomplete-w1 { background:url(img/shadow.png) no-repeat bottom right; position:absolute; top:0px; left:0px; margin:6px 0 0 6px; /* IE6 fix: */ _background:none; _margin:1px 0 0 0; }
.autocomplete { border:1px solid #999; background:#FFF; cursor:default; text-align:left; max-height:350px; overflow:auto; margin:-6px 6px 6px -6px; /* IE6 specific: */ _height:350px; _margin:0; _overflow-x:hidden; }
.autocomplete .selected { background:#F0F0F0; }
.autocomplete div { padding:2px 5px; white-space:nowrap; overflow:hidden; }
.autocomplete strong { font-weight:normal; color:#3399FF; }</pre>
<p><a href="http://www.devbridge.com/projects/autocomplete/jquery/" target="_blank"><strong>Website</strong></a> &#8211; <a href="http://www.devbridge.com/projects/autocomplete/jquery/#download" target="_blank"><strong>Download</strong></a></p>
]]></content:encoded>
			<wfw:commentRss>http://jqueryblog.net/2009/11/jquery-autocomplete-plugin/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

