<?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>Learning jQuery &#187; jQuery UI</title>
	<atom:link href="http://www.learningjquery.com/category/jquery-ui/feed" rel="self" type="application/rss+xml" />
	<link>http://www.learningjquery.com</link>
	<description>Tips, techniques, and tutorials for the jQuery JavaScript library</description>
	<lastBuildDate>Tue, 17 Jan 2012 14:14:01 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Autocomplete Migration Guide</title>
		<link>http://www.learningjquery.com/2010/06/autocomplete-migration-guide</link>
		<comments>http://www.learningjquery.com/2010/06/autocomplete-migration-guide#comments</comments>
		<pubDate>Wed, 23 Jun 2010 13:28:54 +0000</pubDate>
		<dc:creator>Jörn Zaefferer</dc:creator>
				<category><![CDATA[Intermediate]]></category>
		<category><![CDATA[jQuery UI]]></category>

		<guid isPermaLink="false">http://www.learningjquery.com/?p=1106</guid>
		<description><![CDATA[The jQuery Autocomplete plugin got a successor recently, the jQuery UI Autocomplete. In this guide we'll look at the old plugin API step-by-step, and how to migrate to the new API. At first it may look like the new plugin supports barely any of the old options. We'll see how all the old options can [...]]]></description>
			<content:encoded><![CDATA[<p>The <a href="http://bassistance.de/jquery-plugins/jquery-plugin-autocomplete/">jQuery Autocomplete plugin</a> got a successor recently, the <a href="http://jqueryui.com/demos/autocomplete/">jQuery UI Autocomplete</a>. In this guide we'll look at the <a href="http://docs.jquery.com/Plugins/Autocomplete/autocomplete#url_or_dataoptions">old plugin API</a> step-by-step, and how to migrate to the new API.</p>

<p>At first it may look like the new plugin supports barely any of the old options. We'll see how all the old options can be implemented using the three new options and the six events.</p>

<p>The old plugin had two arguments: data or url, and options. Lets start with that data-or-url argument. With the new autocomplete plugin, you'll just pass the data or url to the <code>source</code> option.</p>

<p>So, with the old plugin you'd have this code:</p>

<div class="igBar"><span id="ljavascript-3"><a href="#" onclick="javascript:showPlainTxt('javascript-3'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-3">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;input&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">autocomplete</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;a&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;b&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;c&quot;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>;</div></li>
</ol></div>
</div></div><br />

<p>And that becomes, easy enough:</p>

<div class="igBar"><span id="ljavascript-4"><a href="#" onclick="javascript:showPlainTxt('javascript-4'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-4">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;input&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">autocomplete</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; source<span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #3366CC;">&quot;a&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;b&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;c&quot;</span><span style="color: #009900;">&#93;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
</ol></div>
</div></div><br />

<p>The same applies if you provided a URL as the first argument, although there is a difference between the two plugins for remote data. The old plugin expected a special format with pipes to separate values and newlines to separate rows. That is gone for good, the Autocomplete widget now works with JSON by default. The simplest form is the same as in the example above, an array of string values.</p>

<p>Instead of an array of strings, the widget also accepts an array of objects, with at least a label or value property, or both, in addition to whatever else you need. More on that can be found in the documentation and various demos, eg. <a href="http://jqueryui.com/demos/autocomplete/#custom-data">the Custom Data demo</a> shows how to use custom properties and even display them.</p>

<p>Lets look through the rest of the options for the old plugin, and what to do with them for the new plugin:</p>
<ul>
    <li><strong>autoFill</strong>: Gone with no immediate replacement available, for good reasons: The default behaviour when selecting items via keyboard now puts the focussed value into the input, like the Firefox Awesomebar does it. It's not the same as what the autoFill option did, but there should be no need to recreate that effect.</li>
    <li><strong>cacheLength</strong>: There is no built-in caching support anymore, but it's really easy to implement your own, as shown by the <a href="http://jqueryui.com/demos/autocomplete/#remote-with-cache">Remote with caching demo</a>.</li>
    <li><strong>delay</strong>: Still exists with the same behaviour, but the default is always 300 milliseconds.</li>
    <li><strong>extraParams</strong>: Extra params and all other Ajax related options can be customized by using a callback for the <code>source</code> option. Use <code>$.ajax</code> to send the actual request, with the <code>response</code> callback argument passed to <code>source</code> as the <code>success</code> callback for the <code>$.ajax</code> call. The <a href="http://jqueryui.com/demos/autocomplete/#remote-jsonp">Remote JSONP datasource demo</a> has an example for that.</li>
    <li><strong>formatItem, formatMatch, formatResult, highlight</strong>: All gone, instead use the <code>source</code> option to either provide the formatted data from your serverside, or implement a custom source to do special formatting. The <a href="http://jqueryui.com/demos/autocomplete/#combobox">combobox demo</a> shows how to do that, with a more <a href="http://www.learningjquery.com/2010/06/a-jquery-ui-combobox-under-the-hood">extensive explanation of that demo right on this site</a>.</li>
    <li><strong>matchCase, matchContains, matchSubset</strong>: All gone, too. The builtin matcher for local data will do a case-insensitive match-contains, everything else has to be implemented on the serverside or using the source option. The combobox linked just above also has an example for that.</li>
    <li><strong>max</strong>: Gone; if your server sends too many items, pass a function for the <code>source</code> option that calls <code>$.ajax</code> and truncates or filters the resulting list.</li>
    <li><strong>minChars</strong>: Still present, but was renamed to <code>minLength</code>. Behaves just the same, even the default is still the same, with <code>minLength: 1</code>.</li>
    <li><strong>multiple, multipleSeperator</strong>: Not built-in anymore, but easy to recreate. There are two demos for this, <a href="http://jqueryui.com/demos/autocomplete/#multiple">once with local data</a>, <a href="http://jqueryui.com/demos/autocomplete/#multiple-remote">once with remote data</a>.</li>
    <li><strong>mustMatch</strong>: Gone, but easy to implement with the <code>select</code> event. Once more, the <a href="http://jqueryui.com/demos/autocomplete/#combobox">combobox provides an example</a> for that.</li>
    <li><strong>scroll, scrollHeight</strong>: These option are gone, but the underlying Menu widget actually has support for scrolling. If you have enough items and specify a height via CSS, the menu will scroll.</li>
    <li><strong>selectFirst</strong>: Similar to autoFill (at the top of this list), this option is gone and has now immediate replacement, nor a need for one. The behaviour for selecting values is solid enough to make this option redundant.</li>
    <li><strong>width</strong>: Gone and not required anymore. The menu will automatically be as wide as the input it completes, or wider, as the content requires. And you can always restrict with width using CSS.</li>
</ul>

<p>And thats about it. If you're still looking for a particular replacement, take a look at the various events available, and study the use of the source-option within the various demos. If you still have a question, post on the <a href="http://forum.jquery.com/using-jquery-ui">Using jQuery UI forum</a>. If you spot some mistake or see something that can be improved in this article, please let us know in the comments.</p>]]></content:encoded>
			<wfw:commentRss>http://www.learningjquery.com/2010/06/autocomplete-migration-guide/feed</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>A jQuery UI Combobox: Under the hood</title>
		<link>http://www.learningjquery.com/2010/06/a-jquery-ui-combobox-under-the-hood</link>
		<comments>http://www.learningjquery.com/2010/06/a-jquery-ui-combobox-under-the-hood#comments</comments>
		<pubDate>Tue, 08 Jun 2010 10:00:15 +0000</pubDate>
		<dc:creator>Jörn Zaefferer</dc:creator>
				<category><![CDATA[Intermediate]]></category>
		<category><![CDATA[jQuery UI]]></category>

		<guid isPermaLink="false">http://www.learningjquery.com/?p=1055</guid>
		<description><![CDATA[Update on 2010-08-17: This article was updated to reflect the changes to the combobox code in jQuery UI 1.8.4 The jQuery UI 1.8 release brings along the new autocomplete widget. An autocomplete adds a list of suggestions to an input field, displayed and filtered while the user is typing. This could be attached to a [...]]]></description>
			<content:encoded><![CDATA[<strong>Update on 2010-08-17: This article was updated to reflect the changes to the combobox code in <a href="http://blog.jqueryui.com/2010/08/jquery-ui-1-8-4/">jQuery UI 1.8.4</a></strong>

<p>The <a href="http://blog.jqueryui.com/2010/03/jquery-ui-18/">jQuery UI 1.8 release</a> brings along the new <a href="http://jqueryui.com/demos/autocomplete/">autocomplete widget</a>. An autocomplete adds a list of suggestions to an input field, displayed and filtered while the user is typing. This could be attached to a search field, suggesting either search terms or just matching results for faster navigation. But what if there is a fixed list of options, usually implemented as a standard HTML <code>select</code> element, where the ability to filter would help users find the right value way faster?</p>

<p>That's a "combobox." A combobox works like a select, but also has an input field to filter the options by typing. jQuery UI 1.8 actually provides a sample implementation of a <a href="http://jqueryui.com/demos/autocomplete/#combobox">combobox as a demo</a>. In this article, we'll look under the hood of the combobox demo, to explore both the combobox widget and the autocomplete widget that it uses.</p>

<p>Let's starts with the initial markup:</p>
<span id="more-1055"></span>
<div class="igBar"><span id="lhtml-15"><a href="#" onclick="javascript:showPlainTxt('html-15'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">HTML:</span><br /><div id="html-15">
<div class="html" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;"><span style="color: #000000;">&lt;label&gt;</span></span>Your preferred programming language: <span style="color: #009900;"><span style="color: #000000;">&lt;/label&gt;</span></span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;"><span style="color: #000000;">&lt;select&gt;</span></span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;"><span style="color: #000000;">&lt;option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;a&quot;</span><span style="color: #000000;">&gt;</span></span>asp<span style="color: #009900;"><span style="color: #000000;">&lt;/option&gt;</span></span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;"><span style="color: #000000;">&lt;option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;c&quot;</span><span style="color: #000000;">&gt;</span></span>c<span style="color: #009900;"><span style="color: #000000;">&lt;/option&gt;</span></span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;"><span style="color: #000000;">&lt;option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;cpp&quot;</span><span style="color: #000000;">&gt;</span></span>c++<span style="color: #009900;"><span style="color: #000000;">&lt;/option&gt;</span></span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;"><span style="color: #000000;">&lt;option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;cf&quot;</span><span style="color: #000000;">&gt;</span></span>coldfusion<span style="color: #009900;"><span style="color: #000000;">&lt;/option&gt;</span></span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;"><span style="color: #000000;">&lt;option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;g&quot;</span><span style="color: #000000;">&gt;</span></span>groovy<span style="color: #009900;"><span style="color: #000000;">&lt;/option&gt;</span></span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;"><span style="color: #000000;">&lt;option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;h&quot;</span><span style="color: #000000;">&gt;</span></span>haskell<span style="color: #009900;"><span style="color: #000000;">&lt;/option&gt;</span></span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;"><span style="color: #000000;">&lt;option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;j&quot;</span><span style="color: #000000;">&gt;</span></span>java<span style="color: #009900;"><span style="color: #000000;">&lt;/option&gt;</span></span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;"><span style="color: #000000;">&lt;option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;js&quot;</span><span style="color: #000000;">&gt;</span></span>javascript<span style="color: #009900;"><span style="color: #000000;">&lt;/option&gt;</span></span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;"><span style="color: #000000;">&lt;option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;p1&quot;</span><span style="color: #000000;">&gt;</span></span>perl<span style="color: #009900;"><span style="color: #000000;">&lt;/option&gt;</span></span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;"><span style="color: #000000;">&lt;option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;p2&quot;</span><span style="color: #000000;">&gt;</span></span>php<span style="color: #009900;"><span style="color: #000000;">&lt;/option&gt;</span></span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;"><span style="color: #000000;">&lt;option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;p3&quot;</span><span style="color: #000000;">&gt;</span></span>python<span style="color: #009900;"><span style="color: #000000;">&lt;/option&gt;</span></span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;"><span style="color: #000000;">&lt;option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;r&quot;</span><span style="color: #000000;">&gt;</span></span>ruby<span style="color: #009900;"><span style="color: #000000;">&lt;/option&gt;</span></span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;"><span style="color: #000000;">&lt;option</span> <span style="color: #000066;">value</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;s&quot;</span><span style="color: #000000;">&gt;</span></span>scala<span style="color: #009900;"><span style="color: #000000;">&lt;/option&gt;</span></span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;"><span style="color: #000000;">&lt;/select&gt;</span></span></div></li>
</ol></div>
</div></div><br />

<p>Nothing special there, just a label and a select element with a few options.</p>

<p>The code to apply the combobox widget to the select is quite simple, too:</p>

<div class="igBar"><span id="ljavascript-16"><a href="#" onclick="javascript:showPlainTxt('javascript-16'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-16">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;select&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">combobox</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;</div></li>
</ol></div>
</div></div><br />

<p>Let's look at the code for this combobox widget. First, the full code, to give you an overview. We'll dig into the details step-by-step afterwards.</p>

<div class="igBar"><span id="ljavascript-17"><a href="#" onclick="javascript:showPlainTxt('javascript-17'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-17">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">$.<span style="color: #660066;">widget</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;ui.combobox&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; _create<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> self <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> <a href="/wp-content/themes/ljq/docs-1.7.php?fn=select"><span style="">select</span></a> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">element</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=hide"><span style="">hide</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; selected <span style="color: #339933;">=</span> <a href="/wp-content/themes/ljq/docs-1.7.php?fn=select"><span style="">select</span></a>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=children"><span style="">children</span></a><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;:selected&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; value <span style="color: #339933;">=</span> selected.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=val"><span style="">val</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> selected.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=text"><span style="">text</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;&quot;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> input <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;&lt;input /&gt;&quot;</span> <span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; .<a href="/wp-content/themes/ljq/docs-1.7.php?fn=insertAfter"><span style="">insertAfter</span></a><span style="color: #009900;">&#40;</span><a href="/wp-content/themes/ljq/docs-1.7.php?fn=select"><span style="">select</span></a><span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; .<a href="/wp-content/themes/ljq/docs-1.7.php?fn=val"><span style="">val</span></a><span style="color: #009900;">&#40;</span> value <span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; .<span style="color: #660066;">autocomplete</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="/wp-content/themes/ljq/docs-1.7.php?fn=delay"><span style="">delay</span></a><span style="color: #339933;">:</span> <span style="color: #CC0000;color:#800000;">0</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; minLength<span style="color: #339933;">:</span> <span style="color: #CC0000;color:#800000;">0</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; source<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>request<span style="color: #339933;">,</span> response<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> matcher <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> RegExp<span style="color: #009900;">&#40;</span> $.<span style="color: #660066;">ui</span>.<span style="color: #660066;">autocomplete</span>.<span style="color: #660066;">escapeRegex</span><span style="color: #009900;">&#40;</span>request.<span style="color: #660066;">term</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;i&quot;</span> <span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; response<span style="color: #009900;">&#40;</span> <a href="/wp-content/themes/ljq/docs-1.7.php?fn=select"><span style="">select</span></a>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=children"><span style="">children</span></a><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;option&quot;</span> <span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=map"><span style="">map</span></a><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> <a href="/wp-content/themes/ljq/docs-1.7.php?fn=text"><span style="">text</span></a> <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">this</span> <span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=text"><span style="">text</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">value</span> &#038;& <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span>request.<span style="color: #660066;">term</span> <span style="color: #339933;">||</span> matcher.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span><a href="/wp-content/themes/ljq/docs-1.7.php?fn=text"><span style="">text</span></a><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; label<span style="color: #339933;">:</span> <a href="/wp-content/themes/ljq/docs-1.7.php?fn=text"><span style="">text</span></a>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">new</span> RegExp<span style="color: #009900;">&#40;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;(?![^&#038;;]+;)(?!&lt;[^&lt;&gt;]*)(&quot;</span> <span style="color: #339933;">+</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $.<span style="color: #660066;">ui</span>.<span style="color: #660066;">autocomplete</span>.<span style="color: #660066;">escapeRegex</span><span style="color: #009900;">&#40;</span>request.<span style="color: #660066;">term</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;)(?![^&lt;&gt;]*&gt;)(?![^&#038;;]+;)&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;gi&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;&lt;strong&gt;$1&lt;/strong&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; value<span style="color: #339933;">:</span> <a href="/wp-content/themes/ljq/docs-1.7.php?fn=text"><span style="">text</span></a><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; option<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">this</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="/wp-content/themes/ljq/docs-1.7.php?fn=select"><span style="">select</span></a><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span> event<span style="color: #339933;">,</span> ui <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ui.<span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">option</span>.<span style="color: #660066;">selected</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; self._trigger<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;selected&quot;</span><span style="color: #339933;">,</span> event<span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">item</span><span style="color: #339933;">:</span> ui.<span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">option</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; <a href="/wp-content/themes/ljq/docs-1.7.php?fn=change"><span style="">change</span></a><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #339933;">,</span> ui<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span>ui.<span style="color: #000066; font-weight: bold;">item</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> matcher <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> RegExp<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;^&quot;</span> <span style="color: #339933;">+</span> $.<span style="color: #660066;">ui</span>.<span style="color: #660066;">autocomplete</span>.<span style="color: #660066;">escapeRegex</span><span style="color: #009900;">&#40;</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=val"><span style="">val</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;$&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;i&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; valid <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="/wp-content/themes/ljq/docs-1.7.php?fn=select"><span style="">select</span></a>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=children"><span style="">children</span></a><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;option&quot;</span> <span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=each"><span style="">each</span></a><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">value</span>.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span> matcher <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">selected</span> <span style="color: #339933;">=</span> valid <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span>valid <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// remove invalid value, as it didn't match anything</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">this</span> <span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=val"><span style="">val</span></a><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;&quot;</span> <span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <a href="/wp-content/themes/ljq/docs-1.7.php?fn=select"><span style="">select</span></a>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=val"><span style="">val</span></a><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;&quot;</span> <span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; .<a href="/wp-content/themes/ljq/docs-1.7.php?fn=addClass"><span style="">addClass</span></a><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ui-widget ui-widget-content ui-corner-left&quot;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; </div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; input.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=data"><span style="">data</span></a><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;autocomplete&quot;</span> <span style="color: #009900;">&#41;</span>._renderItem <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span> ul<span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">item</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> $<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;&lt;li&gt;&lt;/li&gt;&quot;</span> <span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; .<a href="/wp-content/themes/ljq/docs-1.7.php?fn=data"><span style="">data</span></a><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;item.autocomplete&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">item</span> <span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; .<a href="/wp-content/themes/ljq/docs-1.7.php?fn=append"><span style="">append</span></a><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;&lt;a&gt;&quot;</span> <span style="color: #339933;">+</span> <span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">label</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;&lt;/a&gt;&quot;</span> <span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; .<a href="/wp-content/themes/ljq/docs-1.7.php?fn=appendTo"><span style="">appendTo</span></a><span style="color: #009900;">&#40;</span> ul <span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #009900;">&#125;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; </div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; $<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;&lt;button&gt;&nbsp;&lt;/button&gt;&quot;</span> <span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; .<a href="/wp-content/themes/ljq/docs-1.7.php?fn=attr"><span style="">attr</span></a><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;tabIndex&quot;</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #CC0000;color:#800000;">1</span> <span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; .<a href="/wp-content/themes/ljq/docs-1.7.php?fn=attr"><span style="">attr</span></a><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;title&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;Show All Items&quot;</span> <span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; .<a href="/wp-content/themes/ljq/docs-1.7.php?fn=insertAfter"><span style="">insertAfter</span></a><span style="color: #009900;">&#40;</span> input <span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; .<span style="color: #660066;">button</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; icons<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; primary<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;ui-icon-triangle-1-s&quot;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <a href="/wp-content/themes/ljq/docs-1.7.php?fn=text"><span style="">text</span></a><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; .<a href="/wp-content/themes/ljq/docs-1.7.php?fn=removeClass"><span style="">removeClass</span></a><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;ui-corner-all&quot;</span> <span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; .<a href="/wp-content/themes/ljq/docs-1.7.php?fn=addClass"><span style="">addClass</span></a><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;ui-corner-right ui-button-icon&quot;</span> <span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; .<a href="/wp-content/themes/ljq/docs-1.7.php?fn=click"><span style="">click</span></a><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// close if already visible</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>input.<span style="color: #660066;">autocomplete</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;widget&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066; font-weight: bold;">is</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;:visible&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; input.<span style="color: #660066;">autocomplete</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;close&quot;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// pass empty string as value to search for, displaying all results</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; input.<span style="color: #660066;">autocomplete</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;search&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; input.<span style="color: #000066;">focus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
</ol></div>
</div></div><br />

<p>Let's break this down, piece by piece:</p>

<div class="igBar"><span id="ljavascript-18"><a href="#" onclick="javascript:showPlainTxt('javascript-18'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-18">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">$.<span style="color: #660066;">widget</span><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;ui.combobox&quot;</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; _create<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// all the code</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
</ol></div>
</div></div><br />

<p>This defines a new widget, in the <code>ui</code> namespace (don't use this for your own widgets, it's reserved for jQuery UI widgets) and adds the only method, <code>_create</code>. This is the constructor method for jQuery UI widgets, and will be called only once. In versions prior to 1.8 it was called <code>_init</code>. The <code>_init</code> method still exists, but it is called each time you call <code>.combobox()</code> (with or without options). Keep in mind that our widget implementation is not complete, as it lacks the <code>destroy</code> method. It's just a demo.</p>

<p>Coming up next is the creation of an input element and applying the autocomplete to it, with data provided by the <code>select</code> element.</p>

<div class="igBar"><span id="ljavascript-19"><a href="#" onclick="javascript:showPlainTxt('javascript-19'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-19">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #003366; font-weight: bold;">var</span> self <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #003366; font-weight: bold;">var</span> <a href="/wp-content/themes/ljq/docs-1.7.php?fn=select"><span style="">select</span></a> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">element</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=hide"><span style="">hide</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; selected <span style="color: #339933;">=</span> <a href="/wp-content/themes/ljq/docs-1.7.php?fn=select"><span style="">select</span></a>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=children"><span style="">children</span></a><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;:selected&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; value <span style="color: #339933;">=</span> selected.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=val"><span style="">val</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> selected.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=text"><span style="">text</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;&quot;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #003366; font-weight: bold;">var</span> input <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;&lt;input /&gt;&quot;</span><span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; .<a href="/wp-content/themes/ljq/docs-1.7.php?fn=insertAfter"><span style="">insertAfter</span></a><span style="color: #009900;">&#40;</span><a href="/wp-content/themes/ljq/docs-1.7.php?fn=select"><span style="">select</span></a><span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; .<a href="/wp-content/themes/ljq/docs-1.7.php?fn=val"><span style="">val</span></a><span style="color: #009900;">&#40;</span> value <span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; .<span style="color: #660066;">autocomplete</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <a href="/wp-content/themes/ljq/docs-1.7.php?fn=delay"><span style="">delay</span></a><span style="color: #339933;">:</span> <span style="color: #CC0000;color:#800000;">0</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; minLength<span style="color: #339933;">:</span> <span style="color: #CC0000;color:#800000;">0</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; source<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>request<span style="color: #339933;">,</span> response<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// implements retrieving and filtering data from the select</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <a href="/wp-content/themes/ljq/docs-1.7.php?fn=select"><span style="">select</span></a><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>request<span style="color: #339933;">,</span> response<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// implements first part of updating the select with the selection</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <a href="/wp-content/themes/ljq/docs-1.7.php?fn=change"><span style="">change</span></a><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #339933;">,</span> ui<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// implements second part of updating the select with the selection</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; .<a href="/wp-content/themes/ljq/docs-1.7.php?fn=addClass"><span style="">addClass</span></a><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;ui-widget ui-widget-content ui-corner-left&quot;</span><span style="color: #009900;">&#41;</span>;</div></li>
</ol></div>
</div></div><br />

<p>It starts with a few variable declarations: <code>var self = this</code> will be used inside callbacks below, where <code>this</code> will refer to something else. The <code>var select</code> references the <code>select</code> element on which the combobox gets applied. To replace the <code>select</code> with the text <code>input</code>, the <code>select</code> is hidden.</p>

<p>The selected and value variables are used to initialized the autocomplete with the current value of the select.</p>

<p>An <code>input</code> element is created from scratch, inserted after the <code>select</code> element into the DOM, and transformed into an autocomplete widget. All three autocomplete options are customized:</p>
<ul>
  <li><strong>delay</strong> specifies the amount of time to wait for displaying data between each key press, here set to zero as the data is local</li>
  <li><strong>minLength</strong> is set to 0, too, so that a cursor-down or -up key press will display the autocomplete menu, even when nothing was entered.</li>
  <li><strong>source</strong> provides the filtered data to display</li>
</ul>

<p>Let's break down the <code>source</code> implementation:</p>

<div class="igBar"><span id="ljavascript-20"><a href="#" onclick="javascript:showPlainTxt('javascript-20'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-20">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">source<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>request<span style="color: #339933;">,</span> response<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #003366; font-weight: bold;">var</span> matcher <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> RegExp<span style="color: #009900;">&#40;</span> $.<span style="color: #660066;">ui</span>.<span style="color: #660066;">autocomplete</span>.<span style="color: #660066;">escapeRegex</span><span style="color: #009900;">&#40;</span>request.<span style="color: #660066;">term</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;i&quot;</span> <span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; response<span style="color: #009900;">&#40;</span> <a href="/wp-content/themes/ljq/docs-1.7.php?fn=select"><span style="">select</span></a>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=children"><span style="">children</span></a><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;option&quot;</span> <span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=map"><span style="">map</span></a><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> <a href="/wp-content/themes/ljq/docs-1.7.php?fn=text"><span style="">text</span></a> <span style="color: #339933;">=</span> $<span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">this</span> <span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=text"><span style="">text</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">value</span> &#038;& <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span>request.<span style="color: #660066;">term</span> <span style="color: #339933;">||</span> matcher.<span style="color: #660066;">test</span><span style="color: #009900;">&#40;</span><a href="/wp-content/themes/ljq/docs-1.7.php?fn=text"><span style="">text</span></a><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; label<span style="color: #339933;">:</span> <a href="/wp-content/themes/ljq/docs-1.7.php?fn=text"><span style="">text</span></a>.<span style="color: #660066;">replace</span><span style="color: #009900;">&#40;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">new</span> RegExp<span style="color: #009900;">&#40;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;(?![^&#038;;]+;)(?!&lt;[^&lt;&gt;]*)(&quot;</span> <span style="color: #339933;">+</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $.<span style="color: #660066;">ui</span>.<span style="color: #660066;">autocomplete</span>.<span style="color: #660066;">escapeRegex</span><span style="color: #009900;">&#40;</span>request.<span style="color: #660066;">term</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;)(?![^&lt;&gt;]*&gt;)(?![^&#038;;]+;)&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;gi&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #3366CC;">&quot;&lt;strong&gt;$1&lt;/strong&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; value<span style="color: #339933;">:</span> <a href="/wp-content/themes/ljq/docs-1.7.php?fn=text"><span style="">text</span></a><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; option<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">this</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span></div></li>
</ol></div>
</div></div><br />

<p>There is a bit of matching and mapping involved here: At first, a regular expression object is defined, based on the entered term, escaped with the help of the <code>$.ui.autocomplte.escapeRegex</code> utility method. This regex gets reused in the function below. The <code>response</code> argument, a callback, gets called, to provide the data to display. The argument passed is the result of the call to <code>select.find("option").map(callback)</code>. That finds all <code>option</code> elements within our original <code>select</code>, then maps each <code>option</code> to a different object, implemented in another callback passed to the <code>map</code> method.</p>

<p>This callback will return <code>undefined</code>, thereby removing an item, when a search term is present and the text of the option doesn't match the entered value. Otherwise (no term, or it matches), it'll return an object with three properties:</p>
<ul>
  <li><strong>label</strong>: based on the text of the option, with the matched term highlighted with some regexing (another example of a write-only regular expression)</li>
  <li><strong>value</strong>: the unmodified text of the option, to be inserted into the text input field</li>
  <li><strong>option</strong>: the option element itself, to update the select (via the selected-property) or to pass on in custom events</li>
</ul>

<p>The <strong>label</strong> and <strong>value</strong> properties are expected by the autocomplete widget, the <strong>option</strong> property has an arbitrary name, used here only by the combobox widget.</p>

<p>Before, I mentioned that the combobox widget customizes all three autocomplete options, but there were actually five options specified. The fourth and fifth properties, <code>select</code> and <code>change</code>, are event. This is the select implementation:</p>

<div class="igBar"><span id="ljavascript-21"><a href="#" onclick="javascript:showPlainTxt('javascript-21'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-21">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><a href="/wp-content/themes/ljq/docs-1.7.php?fn=select"><span style="">select</span></a><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #339933;">,</span> ui<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; ui.<span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">option</span>.<span style="color: #660066;">selected</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; self._trigger<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;selected&quot;</span><span style="color: #339933;">,</span> event<span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">item</span><span style="color: #339933;">:</span> ui.<span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">option</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span></div></li>
</ol></div>
</div></div><br />

<p>The <code>ui.item</code> argument refers to the data we provided in the source option. Via the <code>ui.item.option</code> property we can update the underlying select to the selected item, as well as triggering a selected events for further customization of the combobox widget.</p> 

<p>To cover the case where no selection is made, the change event is used:</p>

<div class="igBar"><span id="ljavascript-22"><a href="#" onclick="javascript:showPlainTxt('javascript-22'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-22">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><a href="/wp-content/themes/ljq/docs-1.7.php?fn=change"><span style="">change</span></a><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #339933;">,</span> ui<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span>ui.<span style="color: #000066; font-weight: bold;">item</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #003366; font-weight: bold;">var</span> matcher <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> RegExp<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;^&quot;</span> <span style="color: #339933;">+</span> $.<span style="color: #660066;">ui</span>.<span style="color: #660066;">autocomplete</span>.<span style="color: #660066;">escapeRegex</span><span style="color: #009900;">&#40;</span> $<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=val"><span style="">val</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;$&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;i&quot;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; valid <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">false</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <a href="/wp-content/themes/ljq/docs-1.7.php?fn=select"><span style="">select</span></a>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=children"><span style="">children</span></a><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;option&quot;</span> <span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=each"><span style="">each</span></a><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">value</span>.<span style="color: #660066;">match</span><span style="color: #009900;">&#40;</span> matcher <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">selected</span> <span style="color: #339933;">=</span> valid <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">true</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span>valid <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #006600; font-style: italic;">// remove invalid value, as it didn't match anything</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; $<span style="color: #009900;">&#40;</span> <span style="color: #000066; font-weight: bold;">this</span> <span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=val"><span style="">val</span></a><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;&quot;</span> <span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <a href="/wp-content/themes/ljq/docs-1.7.php?fn=select"><span style="">select</span></a>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=val"><span style="">val</span></a><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;&quot;</span> <span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span> <span style="color: #003366; font-weight: bold;">false</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span></div></li>
</ol></div>
</div></div><br />

<p>Here the entered value is used to try and match a selection. If the value doesn't match anything, it'll get removed, and the underlying select is set to an empty value, too.</p>

<p>The next block customizes the _renderItem method of the underlying autocomplete. This is necessary to output the highlighting on each row, as autocomplete by default will escape any html.</p>
	
<div class="igBar"><span id="ljavascript-23"><a href="#" onclick="javascript:showPlainTxt('javascript-23'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-23">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">input.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=data"><span style="">data</span></a><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;autocomplete&quot;</span> <span style="color: #009900;">&#41;</span>._renderItem <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span> ul<span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">item</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #000066; font-weight: bold;">return</span> $<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;&lt;li&gt;&lt;/li&gt;&quot;</span> <span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; .<a href="/wp-content/themes/ljq/docs-1.7.php?fn=data"><span style="">data</span></a><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;item.autocomplete&quot;</span><span style="color: #339933;">,</span> <span style="color: #000066; font-weight: bold;">item</span> <span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; .<a href="/wp-content/themes/ljq/docs-1.7.php?fn=append"><span style="">append</span></a><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;&lt;a&gt;&quot;</span> <span style="color: #339933;">+</span> <span style="color: #000066; font-weight: bold;">item</span>.<span style="color: #660066;">label</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;&lt;/a&gt;&quot;</span> <span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; .<a href="/wp-content/themes/ljq/docs-1.7.php?fn=appendTo"><span style="">appendTo</span></a><span style="color: #009900;">&#40;</span> ul <span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;">&#125;</span>;</div></li>
</ol></div>
</div></div><br />

<p>And finally, the last block creates the button that opens the full list of options:</p>

<div class="igBar"><span id="ljavascript-24"><a href="#" onclick="javascript:showPlainTxt('javascript-24'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-24">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">$<span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;&lt;button&gt;&nbsp;&lt;/button&gt;&quot;</span> <span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=attr"><span style="">attr</span></a><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;tabIndex&quot;</span><span style="color: #339933;">,</span> <span style="color: #339933;">-</span><span style="color: #CC0000;color:#800000;">1</span> <span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=attr"><span style="">attr</span></a><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;title&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;Show All Items&quot;</span> <span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=insertAfter"><span style="">insertAfter</span></a><span style="color: #009900;">&#40;</span> input <span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">.<span style="color: #660066;">button</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; icons<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; primary<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;ui-icon-triangle-1-s&quot;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <a href="/wp-content/themes/ljq/docs-1.7.php?fn=text"><span style="">text</span></a><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">false</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=removeClass"><span style="">removeClass</span></a><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;ui-corner-all&quot;</span> <span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=addClass"><span style="">addClass</span></a><span style="color: #009900;">&#40;</span> <span style="color: #3366CC;">&quot;ui-corner-right ui-button-icon&quot;</span> <span style="color: #009900;">&#41;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=click"><span style="">click</span></a><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #006600; font-style: italic;">// close if already visible</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>input.<span style="color: #660066;">autocomplete</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;widget&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #000066; font-weight: bold;">is</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;:visible&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; input.<span style="color: #660066;">autocomplete</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;close&quot;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; &nbsp; <span style="color: #000066; font-weight: bold;">return</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #009900;">&#125;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; <span style="color: #006600; font-style: italic;">// pass empty string as value to search for, displaying all results</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; input.<span style="color: #660066;">autocomplete</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;search&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; input.<span style="color: #000066;">focus</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
</ol></div>
</div></div><br />

<p>Another element is created on-the-fly. It gets <code>tabIndex="-1"</code> to take it out of the tab order, as it's mostly useful for mouse interactions. Keyboard interaction is already covered by the <code>input</code> element. It gets a <code>title</code> attribute to provide a tooltip and is inserted after the <code>input</code> element into the DOM. A call to <code>.button()</code> with some options together with a bit of class-mangling transforms the button into a Button widget that displays a down-arrow icon with rounded corners on the right (the input has rounded-corners on the left).</p>

<p>Finally a <code>click</code> event is bound to the button: If the autocomplete menu is already visible, it gets closed, otherwise the autocomplete's <code>search</code> method is called with an empty string as the argument, to search for all elements, independent of the current value within the input. As the input handles keyboard input, it gets focused. Having focus on the button would be useless or would require duplicate keyboard interaction that the input already supports.</p>

<p>And that's it! We can see that the autocomplete widget is flexible enough to allow all this with option customization, events, and calling a few methods. We don't have to "subclass" autocomplete (creating a new widget with the autocomplete as the parent prototype instead of <code>$.widget</code>). Instead, we can make the combobox mostly independent of any internal or private autocomplete methods. For the full experience and latest version, check out the <a href="http://jqueryui.com/demos/autocomplete/#combobox">combobox demo</a> on the <a href="http://jqueryui.com/">jQuery UI</a> site.</p>]]></content:encoded>
			<wfw:commentRss>http://www.learningjquery.com/2010/06/a-jquery-ui-combobox-under-the-hood/feed</wfw:commentRss>
		<slash:comments>55</slash:comments>
		</item>
		<item>
		<title>The Year of jQuery UI</title>
		<link>http://www.learningjquery.com/2009/01/the-year-of-jquery-ui</link>
		<comments>http://www.learningjquery.com/2009/01/the-year-of-jquery-ui#comments</comments>
		<pubDate>Sat, 03 Jan 2009 18:44:56 +0000</pubDate>
		<dc:creator>Karl Swedberg</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[DOM Traversing]]></category>
		<category><![CDATA[Events]]></category>
		<category><![CDATA[jQuery Resources]]></category>
		<category><![CDATA[jQuery UI]]></category>
		<category><![CDATA[Plugins]]></category>
		<category><![CDATA[JavaScript]]></category>

		<guid isPermaLink="false">http://www.learningjquery.com/?p=223</guid>
		<description><![CDATA[Two years ago I made the somewhat immodest claim that 2007 would be the "Year of jQuery." Since then, jQuery's popularity has grown in ways that none of the core contributors could have imagined. Now I'm ready to make another bold pronouncement: 2009 will be the year of jQuery UI. Here's why: jQuery UI 1.6 [...]]]></description>
			<content:encoded><![CDATA[Two years ago I made the somewhat immodest claim that 2007 would be the "<a href="http://www.learningjquery.com/2007/01/the-year-of-jquery">Year of jQuery</a>." Since then, <a href="http://jquery.com">jQuery</a>'s <a href="http://www.google.com/trends?q=jquery">popularity</a> has grown in <a href="http://docs.jquery.com/Sites_Using_jQuery">ways</a> that none of the <a href="http://docs.jquery.com/Contributors">core contributors</a> could have imagined. Now I'm ready to make another bold pronouncement: 2009 will be the year of <a href="http://ui.jquery.com/">jQuery UI</a>. Here's why: <span id="more-223"></span>
<ul>
	<li><strong>jQuery UI 1.6 is shaping up to be a rock-solid re-factoring of the entire library.</strong> With <a href="http://blog.jquery.com/2008/12/31/jquery-ui-16rc3-its-getting-really-close/">RC4 released just two days ago</a>, the UI team have further cleaned up the API while providing a set of tools that are even more extensible and configurable than they were before.</li>
	<li><strong>Better project management and greater transparency</strong>. Over the last year or so, Paul Bakaus has done much more than lead the development of jQuery UI. He has shaped and nurtured a <a href="http://ui.jquery.com/about">team of top-notch JavaScript developers</a> and has opened up <a href="http://jqueryui.pbwiki.com/">a lot of the decision-making process</a> to outside scrutiny. This bodes well for the direction of the project.</li>
	<li><strong>Improved jQuery UI ThemeRoller</strong>. <a href="http://ui.jquery.com/ThemeRoller">ThemeRoller</a>, developed and designed by the folks at <a href="http://www.filamentgroup.com/">Filament Group</a>, was already an amazingly useful and elegant complement to jQuery UI. But now it's even better, with a much-improved CSS framework and lighter CSS footprint, a slick default theme, a cool icon sprite set, and more configuration options. Also, it'll soon be easier than ever to <a href="http://jqueryui.pbwiki.com/jQuery-UI-CSS-Framework">create your own UI widgets</a> that take advantage of the ThemeRoller &mdash; with upcoming tools, documentation, and tutorials for making your site "ThemeRoller-ready." </li>
	<li><strong>Improved documentation and demos</strong>. The <a href="http://docs.jquery.com/UI">documentation wiki</a> has undergone some significant updates in recent months, and the <a href="http://ui.jquery.com/demos">demos</a> went through a complete overhaul in coordination with the 1.6rc4 release.</li>
  <li><strong>More widespread adoption</strong>. As the API changes settle down and the core UI developers have more time to spend on providing more widgets and components, such as a spinner, menu, and colorpicker, more sites are sure to join the likes of WordPress in adopting jQuery UI.  </li>
	<li><strong>A new blog</strong>. While most of the details are still under wraps, a brand new weblog dedicated to learning jQuery UI, similar in quality and scope to <a href="http://www.learningjquery.com/">Learning jQuery</a>, will be online soon. </li>
</ul>
I have had the great pleasure to use jQuery UI on a couple recent projects, and I can honestly say that it has come a long way since its first release a year and a half ago. If you haven't used the UI library before, now is a great time to start. If my prediction comes true, you'll be at <a href="http://www.google.com/trends?q=jquery+ui&amp;ctab=0&amp;geo=all&amp;date=all&amp;sort=0">the forefront of a major trend</a>.

<h4><ins datetime="2009-01-03T21:33:43+00:00">Update:</ins></h4>
I failed to mention that the new blog will be run by jQuery UI developer <a href="http://rdworth.org/">Richard D. Worth</a>. In addition to being a great developer, Richard does an awesome job of promoting and explaining jQuery UI. I'm really looking forward to seeing the good stuff he'll be posting soon.]]></content:encoded>
			<wfw:commentRss>http://www.learningjquery.com/2009/01/the-year-of-jquery-ui/feed</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Introduction to jQuery UI</title>
		<link>http://www.learningjquery.com/2008/07/introduction-to-jquery-ui</link>
		<comments>http://www.learningjquery.com/2008/07/introduction-to-jquery-ui#comments</comments>
		<pubDate>Wed, 02 Jul 2008 17:35:38 +0000</pubDate>
		<dc:creator>Marc Grabanski</dc:creator>
				<category><![CDATA[Announcement]]></category>
		<category><![CDATA[Beginner]]></category>
		<category><![CDATA[Intermediate]]></category>
		<category><![CDATA[jQuery Resources]]></category>
		<category><![CDATA[jQuery UI]]></category>
		<category><![CDATA[Plugins]]></category>

		<guid isPermaLink="false">http://www.learningjquery.com/2008/07/introduction-to-jquery-ui</guid>
		<description><![CDATA[After many months of stellar work, the jQuery UI team has released version 1.5 of their flagship suite of user-interface widgets, components, and effects. This release was focused on bringing you a standardized development API across all of the components, allowing for a more seamless experience when working with the jQuery UI library. A very [...]]]></description>
			<content:encoded><![CDATA[<p>After many months of stellar work, the jQuery UI team has <a href="http://jquery.com/blog/2008/06/09/jquery-ui-v15-released-focus-on-consistent-api-and-effects/">released version 1.5</a> of their flagship suite of user-interface widgets, components, and effects. This release was focused on bringing you a standardized development API across all of the components, allowing for a more seamless experience when working with the jQuery UI library. </p><span id="more-99"></span>

<p>A very exciting CSS theming application was also released with jQuery UI 1.5, called <a href="http://ui.jquery.com/themeroller">ThemeRoller</a>. ThemeRoller is an amazing way to customize the style and colors across all of the jQuery UI components. It comes with a few preset styles, as well as allowing you to create your own. Once you are done, it packages your theme into a zip file that contains all of the images and CSS you need.</p>

<h4>Brief Overview of the jQuery UI Project</h4>
<p>The jQuery UI project was originally created to bring you a set of "official" jQuery plugins. Mature components from the plugins repository were pulled together to form the first release of jQuery UI. But since each of these plugins had its own style, having been written by different authors, the first release of the library felt a bit cumbersome when packaged together. With that in mind, the focus of UI 1.5 was on achieving a coherent, standardized API to eliminate much of the differences between the components. Through much time and effort, many bugs and feature requests were addressed along the way as well.</p>
<h4>Inside Look at jQuery UI Version 1.5</h4>
<p>Before starting, I want to make sure you know where the <a href="http://docs.jquery.com/UI">jQuery UI Documentation</a> is located. You may also want to head to the <a href="http://ui.jquery.com/download">download page</a> to grab the library for yourself. Note that the development bundle is the easiest to get started with.</p>
<p>
First, let's start by including the necessary files for jQuery UI: jQuery latest js file, the Flora theme complete stylesheet, and the core UI file. Each of the components is built on top of these files. Here is how to include them:</p>

<div class="igBar"><span id="lhtml-31"><a href="#" onclick="javascript:showPlainTxt('html-31'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">HTML:</span><br /><div id="html-31">
<div class="html" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;"><span style="color: #000000;">&lt;link</span> <span style="color: #000066;">rel</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;stylesheet&quot;</span> <span style="color: #000066;">href</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;themes/flora/flora.all.css&quot;</span> <span style="color: #000066;">type</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;text/css&quot;</span> <span style="color: #000066;">media</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;screen&quot;</span> <span style="color: #000066;">title</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;Flora (Default)&quot;</span> <span style="color: #66cc66;">/</span><span style="color: #000000;">&gt;</span></span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;"><span style="color: #000000;">&lt;script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;http://code.jquery.com/jquery-latest.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span>script&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;"><span style="color: #000000;">&lt;script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ui/ui.core.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span>script&gt;</span></div></li>
</ol></div>
</div></div><br />

<p>You may want to download these files and put them on your own server, but this is just fine for our demonstration.</p>

<p>At this point you may include the jquery.ui.all.js script for testing, or include each of the components individually. Here are the components that we are using for this demo:</p>

<div class="igBar"><span id="lhtml-32"><a href="#" onclick="javascript:showPlainTxt('html-32'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">HTML:</span><br /><div id="html-32">
<div class="html" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;"><span style="color: #000000;">&lt;script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ui/ui.draggable.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span>script&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;"><span style="color: #000000;">&lt;script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ui/ui.resizable.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span>script&gt;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;"><span style="color: #000000;">&lt;script</span> <span style="color: #000066;">src</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;ui/ui.accordion.js&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span>script&gt;</span></div></li>
</ol></div>
</div></div><br />

<h4>Activating Components</h4>
<p>Each component has a constructor method, which is the component name. For instance, we can make a div draggable by using the <code>draggable()</code> method:</p>

<div class="igBar"><span id="ljavascript-33"><a href="#" onclick="javascript:showPlainTxt('javascript-33'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-33">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=ready"><span style="">ready</span></a><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#dragme&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">draggable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
</ol></div>
</div></div><br />

<div id="dragme" class="draggable"></div>
<p>The component defaults can be overridden by passing in options to the main function. For instance, if we want to make the div drag only horizontally, we can set the axis option to "x" with the following code:</p>

<div class="igBar"><span id="ljavascript-34"><a href="#" onclick="javascript:showPlainTxt('javascript-34'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-34">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=ready"><span style="">ready</span></a><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#dragme-x&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">draggable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> axis<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;x&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
</ol></div>
</div></div><br />

<div id="dragme-x" class="draggable"></div>

<p>Likewise, the Accordion can be accessed the same way. Here we set a custom option to specify the accordion to slide on the mouseover event:</p>

<div class="igBar"><span id="ljavascript-35"><a href="#" onclick="javascript:showPlainTxt('javascript-35'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-35">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=ready"><span style="">ready</span></a><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#accordionDemo&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">accordion</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> event<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;mouseover&quot;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
</ol></div>
</div></div><br />


<ul id="accordionDemo" class="ui-accordion-container" style="width: 400px;"><li><a href='#'>Test 1</a><div>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
</div></li><li><a href='#'>Test 2</a><div>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam <br /></div></li><li><a href='#'>Test 3</a><div>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. </div></li></ul>
<div style="border-top: 1px solid grey"></div>

<p>Some of the components, such as draggable and resizable, can even be combined:</p>

<div class="igBar"><span id="ljavascript-36"><a href="#" onclick="javascript:showPlainTxt('javascript-36'); return false;">PLAIN TEXT</a></span></div><div class="syntax_hilite"><span class="langName">JavaScript:</span><br /><div id="javascript-36">
<div class="javascript" style="font-family:monospace;"><ol><li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">$<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<a href="/wp-content/themes/ljq/docs-1.7.php?fn=ready"><span style="">ready</span></a><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span></div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;">&nbsp; $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#dragme-resize&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">draggable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">resizable</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>;</div></li>
<li style="font-weight: normal; vertical-align:top;color:#ACAA9A;"><div style="background-color: transparent;"><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>;</div></li>
</ol></div>
</div></div><br />

<div id="dragme-resize" class="draggable" style="border:2px solid grey;background:#CDE7B0"></div>

<p>This first makes the div draggable, then adds the resize handles to the div.</p>

<p>Now you should have what you need to start with each of the components! Head to the <a href="http://ui.jquery.com/functional_demos/">functional demos page</a> to see in-depth examples of each of the components.</p>

<h4>Looking at the Future of jQuery UI</h4>
<p>With Paul Bakaus <a href="http://jquery.com/blog/2008/01/23/jquery-ui-and-beyond-the-jquery-liferay-partnership/">hired as (paid) full-time lead of jQuery UI</a>, the project has been energized, charging forward by leaps and bounds. With an <a href="http://docs.jquery.com/UI/Roadmap">ever-growing set of UI components</a>, jQuery UI's future is shaping up to be one of great promise.</p>]]></content:encoded>
			<wfw:commentRss>http://www.learningjquery.com/2008/07/introduction-to-jquery-ui/feed</wfw:commentRss>
		<slash:comments>28</slash:comments>
		</item>
	</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using disk: enhanced (User agent is rejected)
Database Caching 6/27 queries in 0.006 seconds using disk: basic
Object Caching 369/408 objects using disk: basic
Content Delivery Network via learningjquery.kswedberg.netdna-cdn.com

Served from: www.learningjquery.com @ 2012-02-03 22:52:57 -->
