40 |
aurelien |
1 |
|
|
|
2 |
<ul class="UIAPIPlugin-toc">
|
|
|
3 |
<li><a href="#overview">Overview</a></li>
|
|
|
4 |
<li><a href="#options">Options</a></li>
|
|
|
5 |
<li><a href="#events">Events</a></li>
|
|
|
6 |
<li><a href="#methods">Methods</a></li>
|
|
|
7 |
<li><a href="#theming">Theming</a></li>
|
|
|
8 |
</ul>
|
|
|
9 |
<div class="UIAPIPlugin">
|
|
|
10 |
<h1>jQuery UI Autocomplete</h1>
|
|
|
11 |
<div id="overview">
|
|
|
12 |
<h2 class="top-header">Overview</h2>
|
|
|
13 |
<div id="overview-main">
|
|
|
14 |
<p>Autocomplete, when added to an input field, enables users to quickly find and select from a pre-populated list of values as they type, leveraging searching and filtering.</p>
|
|
|
15 |
<p>By giving an Autocomplete field focus or entering something into it, the plugin starts searching for entries that match and displays a list of values to choose from. By entering more characters, the user can filter down the list to better matches.</p>
|
|
|
16 |
<p>This can be used to enter previous selected values, for example you could use Autocomplete for entering tags, to complete an address, you could enter a city name and get the zip code, or maybe enter email addresses from an address book.</p>
|
|
|
17 |
<p>You can pull data in from a local and/or a remote source: Local is good for small data sets (like an address book with 50 entries), remote is necessary for big data sets, like a database with hundreds or millions of entries to select from.</p>
|
|
|
18 |
<p>Autocomplete can be customized to work with various data sources, by just specifying the source option. A data source can be:</p>
|
|
|
19 |
<ul>
|
|
|
20 |
<li>an Array with local data</li>
|
|
|
21 |
<li>a String, specifying a URL</li>
|
|
|
22 |
<li>a Callback</li>
|
|
|
23 |
</ul>
|
|
|
24 |
<p>The local data can be a simple Array of Strings, or it contains Objects for each item in the array, with either a label or value property or both. The label property is displayed in the suggestion menu. The value will be inserted into the input element after the user selected something from the menu. If just one property is specified, it will be used for both, eg. if you provide only value-properties, the value will also be used as the label.</p>
|
|
|
25 |
<p>When a String is used, the Autocomplete plugin expects that string to point to a URL resource that will return JSON data. It can be on the same host or on a different one (must provide JSONP). The request parameter "term" gets added to that URL. The data itself can be in the same format as the local data described above.</p>
|
|
|
26 |
<p>The third variation, the callback, provides the most flexibility, and can be used to connect any data source to Autocomplete. The callback gets two arguments:</p>
|
|
|
27 |
<ul>
|
|
|
28 |
<li>A request object, with a single property called "term", which refers to the value currently in the text input. For example, when the user entered "new yo" in a city field, the Autocomplete term will equal "new yo".</li>
|
|
|
29 |
<li>A response callback, which expects a single argument to contain the data to suggest to the user. This data should be filtered based on the provided term, and can be in any of the formats described above for simple local data (String-Array or Object-Array with label/value/both properties).</li>
|
|
|
30 |
</ul>
|
|
|
31 |
<p>The demos all focus on different variations of the source-option - look for the one that matches your use case, and take a look at the code.</p>
|
|
|
32 |
</div>
|
|
|
33 |
<div id="overview-dependencies">
|
|
|
34 |
<h3>Dependencies</h3>
|
|
|
35 |
<ul>
|
|
|
36 |
<li>UI Core</li>
|
|
|
37 |
<li>UI Widget</li>
|
|
|
38 |
<li>UI Position</li>
|
|
|
39 |
</ul>
|
|
|
40 |
</div>
|
|
|
41 |
<div id="overview-example">
|
|
|
42 |
<h3>Example</h3>
|
|
|
43 |
<div id="overview-example" class="example">
|
|
|
44 |
<ul><li><a href="#demo"><span>Demo</span></a></li><li><a href="#source"><span>View Source</span></a></li></ul>
|
|
|
45 |
<p><div id="demo" class="tabs-container" rel="300">
|
|
|
46 |
A simple jQuery UI Autocomplete.<br />
|
|
|
47 |
</p>
|
|
|
48 |
<pre>$("input#autocomplete").autocomplete({
|
|
|
49 |
source: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"]
|
|
|
50 |
});
|
|
|
51 |
</pre>
|
|
|
52 |
<p></div><div id="source" class="tabs-container">
|
|
|
53 |
</p>
|
|
|
54 |
<pre><!DOCTYPE html>
|
|
|
55 |
<html>
|
|
|
56 |
<head>
|
|
|
57 |
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
|
|
|
58 |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
|
|
|
59 |
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
|
|
|
60 |
|
|
|
61 |
<script>
|
|
|
62 |
$(document).ready(function() {
|
|
|
63 |
$("input#autocomplete").autocomplete({
|
|
|
64 |
source: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"]
|
|
|
65 |
});
|
|
|
66 |
});
|
|
|
67 |
</script>
|
|
|
68 |
</head>
|
|
|
69 |
<body style="font-size:62.5%;">
|
|
|
70 |
|
|
|
71 |
<input id="autocomplete" />
|
|
|
72 |
|
|
|
73 |
</body>
|
|
|
74 |
</html>
|
|
|
75 |
</pre>
|
|
|
76 |
<p></div>
|
|
|
77 |
</p><p></div>
|
|
|
78 |
</div>
|
|
|
79 |
</div>
|
|
|
80 |
<div id="options">
|
|
|
81 |
<h2 class="top-header">Options</h2>
|
|
|
82 |
<ul class="options-list">
|
|
|
83 |
|
|
|
84 |
<li class="option" id="option-disabled">
|
|
|
85 |
<div class="option-header">
|
|
|
86 |
<h3 class="option-name"><a href="#option-disabled">disabled</a></h3>
|
|
|
87 |
<dl>
|
|
|
88 |
<dt class="option-type-label">Type:</dt>
|
|
|
89 |
<dd class="option-type">Boolean</dd>
|
|
|
90 |
|
|
|
91 |
<dt class="option-default-label">Default:</dt>
|
|
|
92 |
<dd class="option-default">false</dd>
|
|
|
93 |
|
|
|
94 |
</dl>
|
|
|
95 |
</div>
|
|
|
96 |
<div class="option-description">
|
|
|
97 |
<p>Disables (true) or enables (false) the autocomplete. Can be set when initialising (first creating) the autocomplete.</p>
|
|
|
98 |
</div>
|
|
|
99 |
<div class="option-examples">
|
|
|
100 |
<h4>Code examples</h4>
|
|
|
101 |
<dl class="option-examples-list">
|
|
|
102 |
|
|
|
103 |
<dt>
|
|
|
104 |
Initialize a autocomplete with the <code>disabled</code> option specified.
|
|
|
105 |
</dt>
|
|
|
106 |
<dd>
|
|
|
107 |
<pre><code>$( ".selector" ).autocomplete({ disabled: true });</code></pre>
|
|
|
108 |
</dd>
|
|
|
109 |
|
|
|
110 |
|
|
|
111 |
<dt>
|
|
|
112 |
Get or set the <code>disabled</code> option, after init.
|
|
|
113 |
</dt>
|
|
|
114 |
<dd>
|
|
|
115 |
<pre><code>//getter
|
|
|
116 |
var disabled = $( ".selector" ).autocomplete( "option", "disabled" );
|
|
|
117 |
//setter
|
|
|
118 |
$( ".selector" ).autocomplete( "option", "disabled", true );</code></pre>
|
|
|
119 |
</dd>
|
|
|
120 |
|
|
|
121 |
</dl>
|
|
|
122 |
</div>
|
|
|
123 |
</li>
|
|
|
124 |
|
|
|
125 |
|
|
|
126 |
<li class="option" id="option-delay">
|
|
|
127 |
<div class="option-header">
|
|
|
128 |
<h3 class="option-name"><a href="#option-delay">delay</a></h3>
|
|
|
129 |
<dl>
|
|
|
130 |
<dt class="option-type-label">Type:</dt>
|
|
|
131 |
<dd class="option-type">Integer</dd>
|
|
|
132 |
|
|
|
133 |
<dt class="option-default-label">Default:</dt>
|
|
|
134 |
<dd class="option-default">300</dd>
|
|
|
135 |
|
|
|
136 |
</dl>
|
|
|
137 |
</div>
|
|
|
138 |
<div class="option-description">
|
|
|
139 |
<p>The delay in milliseconds the Autocomplete waits after a keystroke to activate itself. A zero-delay makes sense for local data (more responsive), but can produce a lot of load for remote data, while being less responsive.</p>
|
|
|
140 |
</div>
|
|
|
141 |
<div class="option-examples">
|
|
|
142 |
<h4>Code examples</h4>
|
|
|
143 |
<dl class="option-examples-list">
|
|
|
144 |
|
|
|
145 |
<dt>
|
|
|
146 |
Initialize a autocomplete with the <code>delay</code> option specified.
|
|
|
147 |
</dt>
|
|
|
148 |
<dd>
|
|
|
149 |
<pre><code>$( ".selector" ).autocomplete({ delay: 0 });</code></pre>
|
|
|
150 |
</dd>
|
|
|
151 |
|
|
|
152 |
|
|
|
153 |
<dt>
|
|
|
154 |
Get or set the <code>delay</code> option, after init.
|
|
|
155 |
</dt>
|
|
|
156 |
<dd>
|
|
|
157 |
<pre><code>//getter
|
|
|
158 |
var delay = $( ".selector" ).autocomplete( "option", "delay" );
|
|
|
159 |
//setter
|
|
|
160 |
$( ".selector" ).autocomplete( "option", "delay", 0 );</code></pre>
|
|
|
161 |
</dd>
|
|
|
162 |
|
|
|
163 |
</dl>
|
|
|
164 |
</div>
|
|
|
165 |
</li>
|
|
|
166 |
|
|
|
167 |
|
|
|
168 |
<li class="option" id="option-minLength">
|
|
|
169 |
<div class="option-header">
|
|
|
170 |
<h3 class="option-name"><a href="#option-minLength">minLength</a></h3>
|
|
|
171 |
<dl>
|
|
|
172 |
<dt class="option-type-label">Type:</dt>
|
|
|
173 |
<dd class="option-type">Integer</dd>
|
|
|
174 |
|
|
|
175 |
<dt class="option-default-label">Default:</dt>
|
|
|
176 |
<dd class="option-default">1</dd>
|
|
|
177 |
|
|
|
178 |
</dl>
|
|
|
179 |
</div>
|
|
|
180 |
<div class="option-description">
|
|
|
181 |
<p>The minimum number of characters a user has to type before the Autocomplete activates. Zero is useful for local data with just a few items. Should be increased when there are a lot of items, where a single character would match a few thousand items.</p>
|
|
|
182 |
</div>
|
|
|
183 |
<div class="option-examples">
|
|
|
184 |
<h4>Code examples</h4>
|
|
|
185 |
<dl class="option-examples-list">
|
|
|
186 |
|
|
|
187 |
<dt>
|
|
|
188 |
Initialize a autocomplete with the <code>minLength</code> option specified.
|
|
|
189 |
</dt>
|
|
|
190 |
<dd>
|
|
|
191 |
<pre><code>$( ".selector" ).autocomplete({ minLength: 0 });</code></pre>
|
|
|
192 |
</dd>
|
|
|
193 |
|
|
|
194 |
|
|
|
195 |
<dt>
|
|
|
196 |
Get or set the <code>minLength</code> option, after init.
|
|
|
197 |
</dt>
|
|
|
198 |
<dd>
|
|
|
199 |
<pre><code>//getter
|
|
|
200 |
var minLength = $( ".selector" ).autocomplete( "option", "minLength" );
|
|
|
201 |
//setter
|
|
|
202 |
$( ".selector" ).autocomplete( "option", "minLength", 0 );</code></pre>
|
|
|
203 |
</dd>
|
|
|
204 |
|
|
|
205 |
</dl>
|
|
|
206 |
</div>
|
|
|
207 |
</li>
|
|
|
208 |
|
|
|
209 |
|
|
|
210 |
<li class="option" id="option-source">
|
|
|
211 |
<div class="option-header">
|
|
|
212 |
<h3 class="option-name"><a href="#option-source">source</a></h3>
|
|
|
213 |
<dl>
|
|
|
214 |
<dt class="option-type-label">Type:</dt>
|
|
|
215 |
<dd class="option-type">String, Array, Callback</dd>
|
|
|
216 |
|
|
|
217 |
<dt class="option-default-label">Default:</dt>
|
|
|
218 |
<dd class="option-default">none, must be specified</dd>
|
|
|
219 |
|
|
|
220 |
</dl>
|
|
|
221 |
</div>
|
|
|
222 |
<div class="option-description">
|
|
|
223 |
<p>Defines the data to use, must be specified. See Overview section for more details, and look at the various demos.
|
|
|
224 |
</p>
|
|
|
225 |
</div>
|
|
|
226 |
<div class="option-examples">
|
|
|
227 |
<h4>Code examples</h4>
|
|
|
228 |
<dl class="option-examples-list">
|
|
|
229 |
|
|
|
230 |
<dt>
|
|
|
231 |
Initialize a autocomplete with the <code>source</code> option specified.
|
|
|
232 |
</dt>
|
|
|
233 |
<dd>
|
|
|
234 |
<pre><code>$( ".selector" ).autocomplete({ source: ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"] });</code></pre>
|
|
|
235 |
</dd>
|
|
|
236 |
|
|
|
237 |
|
|
|
238 |
<dt>
|
|
|
239 |
Get or set the <code>source</code> option, after init.
|
|
|
240 |
</dt>
|
|
|
241 |
<dd>
|
|
|
242 |
<pre><code>//getter
|
|
|
243 |
var source = $( ".selector" ).autocomplete( "option", "source" );
|
|
|
244 |
//setter
|
|
|
245 |
$( ".selector" ).autocomplete( "option", "source", ["c++", "java", "php", "coldfusion", "javascript", "asp", "ruby"] );</code></pre>
|
|
|
246 |
</dd>
|
|
|
247 |
|
|
|
248 |
</dl>
|
|
|
249 |
</div>
|
|
|
250 |
</li>
|
|
|
251 |
|
|
|
252 |
</ul>
|
|
|
253 |
</div>
|
|
|
254 |
<div id="events">
|
|
|
255 |
<h2 class="top-header">Events</h2>
|
|
|
256 |
<ul class="events-list">
|
|
|
257 |
|
|
|
258 |
<li class="event" id="event-search">
|
|
|
259 |
<div class="event-header">
|
|
|
260 |
<h3 class="event-name"><a href="#event-search">search</a></h3>
|
|
|
261 |
<dl>
|
|
|
262 |
<dt class="event-type-label">Type:</dt>
|
|
|
263 |
<dd class="event-type">autocompletesearch</dd>
|
|
|
264 |
</dl>
|
|
|
265 |
</div>
|
|
|
266 |
<div class="event-description">
|
|
|
267 |
<p>Before a request (source-option) is started, after minLength and delay are met. Can be canceled (return false), then no request will be started and no items suggested.</p>
|
|
|
268 |
</div>
|
|
|
269 |
<div class="event-examples">
|
|
|
270 |
<h4>Code examples</h4>
|
|
|
271 |
<dl class="event-examples-list">
|
|
|
272 |
|
|
|
273 |
<dt>
|
|
|
274 |
Supply a callback function to handle the <code>search</code> event as an init option.
|
|
|
275 |
</dt>
|
|
|
276 |
<dd>
|
|
|
277 |
<pre><code>$( ".selector" ).autocomplete({
|
|
|
278 |
search: function(event, ui) { ... }
|
|
|
279 |
});</code></pre>
|
|
|
280 |
</dd>
|
|
|
281 |
|
|
|
282 |
|
|
|
283 |
<dt>
|
|
|
284 |
Bind to the <code>search</code> event by type: <code>autocompletesearch</code>.
|
|
|
285 |
</dt>
|
|
|
286 |
<dd>
|
|
|
287 |
<pre><code>$( ".selector" ).bind( "autocompletesearch", function(event, ui) {
|
|
|
288 |
...
|
|
|
289 |
});</code></pre>
|
|
|
290 |
</dd>
|
|
|
291 |
|
|
|
292 |
</dl>
|
|
|
293 |
</div>
|
|
|
294 |
</li>
|
|
|
295 |
|
|
|
296 |
|
|
|
297 |
<li class="event" id="event-open">
|
|
|
298 |
<div class="event-header">
|
|
|
299 |
<h3 class="event-name"><a href="#event-open">open</a></h3>
|
|
|
300 |
<dl>
|
|
|
301 |
<dt class="event-type-label">Type:</dt>
|
|
|
302 |
<dd class="event-type">autocompleteopen</dd>
|
|
|
303 |
</dl>
|
|
|
304 |
</div>
|
|
|
305 |
<div class="event-description">
|
|
|
306 |
<p>Triggered when the suggestion menu is opened.</p>
|
|
|
307 |
</div>
|
|
|
308 |
<div class="event-examples">
|
|
|
309 |
<h4>Code examples</h4>
|
|
|
310 |
<dl class="event-examples-list">
|
|
|
311 |
|
|
|
312 |
<dt>
|
|
|
313 |
Supply a callback function to handle the <code>open</code> event as an init option.
|
|
|
314 |
</dt>
|
|
|
315 |
<dd>
|
|
|
316 |
<pre><code>$( ".selector" ).autocomplete({
|
|
|
317 |
open: function(event, ui) { ... }
|
|
|
318 |
});</code></pre>
|
|
|
319 |
</dd>
|
|
|
320 |
|
|
|
321 |
|
|
|
322 |
<dt>
|
|
|
323 |
Bind to the <code>open</code> event by type: <code>autocompleteopen</code>.
|
|
|
324 |
</dt>
|
|
|
325 |
<dd>
|
|
|
326 |
<pre><code>$( ".selector" ).bind( "autocompleteopen", function(event, ui) {
|
|
|
327 |
...
|
|
|
328 |
});</code></pre>
|
|
|
329 |
</dd>
|
|
|
330 |
|
|
|
331 |
</dl>
|
|
|
332 |
</div>
|
|
|
333 |
</li>
|
|
|
334 |
|
|
|
335 |
|
|
|
336 |
<li class="event" id="event-focus">
|
|
|
337 |
<div class="event-header">
|
|
|
338 |
<h3 class="event-name"><a href="#event-focus">focus</a></h3>
|
|
|
339 |
<dl>
|
|
|
340 |
<dt class="event-type-label">Type:</dt>
|
|
|
341 |
<dd class="event-type">autocompletefocus</dd>
|
|
|
342 |
</dl>
|
|
|
343 |
</div>
|
|
|
344 |
<div class="event-description">
|
|
|
345 |
<p>Before focus is moved to an item (not selecting), ui.item refers to the focused item. The default action of focus is to replace the text field's value with the value of the focused item, though only if the focus event was triggered by a keyboard interaction. Canceling this event prevents the value from being updated, but does not prevent the menu item from being focused.</p>
|
|
|
346 |
</div>
|
|
|
347 |
<div class="event-examples">
|
|
|
348 |
<h4>Code examples</h4>
|
|
|
349 |
<dl class="event-examples-list">
|
|
|
350 |
|
|
|
351 |
<dt>
|
|
|
352 |
Supply a callback function to handle the <code>focus</code> event as an init option.
|
|
|
353 |
</dt>
|
|
|
354 |
<dd>
|
|
|
355 |
<pre><code>$( ".selector" ).autocomplete({
|
|
|
356 |
focus: function(event, ui) { ... }
|
|
|
357 |
});</code></pre>
|
|
|
358 |
</dd>
|
|
|
359 |
|
|
|
360 |
|
|
|
361 |
<dt>
|
|
|
362 |
Bind to the <code>focus</code> event by type: <code>autocompletefocus</code>.
|
|
|
363 |
</dt>
|
|
|
364 |
<dd>
|
|
|
365 |
<pre><code>$( ".selector" ).bind( "autocompletefocus", function(event, ui) {
|
|
|
366 |
...
|
|
|
367 |
});</code></pre>
|
|
|
368 |
</dd>
|
|
|
369 |
|
|
|
370 |
</dl>
|
|
|
371 |
</div>
|
|
|
372 |
</li>
|
|
|
373 |
|
|
|
374 |
|
|
|
375 |
<li class="event" id="event-select">
|
|
|
376 |
<div class="event-header">
|
|
|
377 |
<h3 class="event-name"><a href="#event-select">select</a></h3>
|
|
|
378 |
<dl>
|
|
|
379 |
<dt class="event-type-label">Type:</dt>
|
|
|
380 |
<dd class="event-type">autocompleteselect</dd>
|
|
|
381 |
</dl>
|
|
|
382 |
</div>
|
|
|
383 |
<div class="event-description">
|
|
|
384 |
<p>Triggered when an item is selected from the menu; ui.item refers to the selected item. The default action of select is to replace the text field's value with the value of the selected item. Canceling this event prevents the value from being updated, but does not prevent the menu from closing.</p>
|
|
|
385 |
</div>
|
|
|
386 |
<div class="event-examples">
|
|
|
387 |
<h4>Code examples</h4>
|
|
|
388 |
<dl class="event-examples-list">
|
|
|
389 |
|
|
|
390 |
<dt>
|
|
|
391 |
Supply a callback function to handle the <code>select</code> event as an init option.
|
|
|
392 |
</dt>
|
|
|
393 |
<dd>
|
|
|
394 |
<pre><code>$( ".selector" ).autocomplete({
|
|
|
395 |
select: function(event, ui) { ... }
|
|
|
396 |
});</code></pre>
|
|
|
397 |
</dd>
|
|
|
398 |
|
|
|
399 |
|
|
|
400 |
<dt>
|
|
|
401 |
Bind to the <code>select</code> event by type: <code>autocompleteselect</code>.
|
|
|
402 |
</dt>
|
|
|
403 |
<dd>
|
|
|
404 |
<pre><code>$( ".selector" ).bind( "autocompleteselect", function(event, ui) {
|
|
|
405 |
...
|
|
|
406 |
});</code></pre>
|
|
|
407 |
</dd>
|
|
|
408 |
|
|
|
409 |
</dl>
|
|
|
410 |
</div>
|
|
|
411 |
</li>
|
|
|
412 |
|
|
|
413 |
|
|
|
414 |
<li class="event" id="event-close">
|
|
|
415 |
<div class="event-header">
|
|
|
416 |
<h3 class="event-name"><a href="#event-close">close</a></h3>
|
|
|
417 |
<dl>
|
|
|
418 |
<dt class="event-type-label">Type:</dt>
|
|
|
419 |
<dd class="event-type">autocompleteclose</dd>
|
|
|
420 |
</dl>
|
|
|
421 |
</div>
|
|
|
422 |
<div class="event-description">
|
|
|
423 |
<p>When the list is hidden - doesn't have to occur together with a change.</p>
|
|
|
424 |
</div>
|
|
|
425 |
<div class="event-examples">
|
|
|
426 |
<h4>Code examples</h4>
|
|
|
427 |
<dl class="event-examples-list">
|
|
|
428 |
|
|
|
429 |
<dt>
|
|
|
430 |
Supply a callback function to handle the <code>close</code> event as an init option.
|
|
|
431 |
</dt>
|
|
|
432 |
<dd>
|
|
|
433 |
<pre><code>$( ".selector" ).autocomplete({
|
|
|
434 |
close: function(event, ui) { ... }
|
|
|
435 |
});</code></pre>
|
|
|
436 |
</dd>
|
|
|
437 |
|
|
|
438 |
|
|
|
439 |
<dt>
|
|
|
440 |
Bind to the <code>close</code> event by type: <code>autocompleteclose</code>.
|
|
|
441 |
</dt>
|
|
|
442 |
<dd>
|
|
|
443 |
<pre><code>$( ".selector" ).bind( "autocompleteclose", function(event, ui) {
|
|
|
444 |
...
|
|
|
445 |
});</code></pre>
|
|
|
446 |
</dd>
|
|
|
447 |
|
|
|
448 |
</dl>
|
|
|
449 |
</div>
|
|
|
450 |
</li>
|
|
|
451 |
|
|
|
452 |
|
|
|
453 |
<li class="event" id="event-change">
|
|
|
454 |
<div class="event-header">
|
|
|
455 |
<h3 class="event-name"><a href="#event-change">change</a></h3>
|
|
|
456 |
<dl>
|
|
|
457 |
<dt class="event-type-label">Type:</dt>
|
|
|
458 |
<dd class="event-type">autocompletechange</dd>
|
|
|
459 |
</dl>
|
|
|
460 |
</div>
|
|
|
461 |
<div class="event-description">
|
|
|
462 |
<p>After an item was selected; ui.item refers to the selected item. Always triggered after the close event.</p>
|
|
|
463 |
</div>
|
|
|
464 |
<div class="event-examples">
|
|
|
465 |
<h4>Code examples</h4>
|
|
|
466 |
<dl class="event-examples-list">
|
|
|
467 |
|
|
|
468 |
<dt>
|
|
|
469 |
Supply a callback function to handle the <code>change</code> event as an init option.
|
|
|
470 |
</dt>
|
|
|
471 |
<dd>
|
|
|
472 |
<pre><code>$( ".selector" ).autocomplete({
|
|
|
473 |
change: function(event, ui) { ... }
|
|
|
474 |
});</code></pre>
|
|
|
475 |
</dd>
|
|
|
476 |
|
|
|
477 |
|
|
|
478 |
<dt>
|
|
|
479 |
Bind to the <code>change</code> event by type: <code>autocompletechange</code>.
|
|
|
480 |
</dt>
|
|
|
481 |
<dd>
|
|
|
482 |
<pre><code>$( ".selector" ).bind( "autocompletechange", function(event, ui) {
|
|
|
483 |
...
|
|
|
484 |
});</code></pre>
|
|
|
485 |
</dd>
|
|
|
486 |
|
|
|
487 |
</dl>
|
|
|
488 |
</div>
|
|
|
489 |
</li>
|
|
|
490 |
|
|
|
491 |
</ul>
|
|
|
492 |
</div>
|
|
|
493 |
<div id="methods">
|
|
|
494 |
<h2 class="top-header">Methods</h2>
|
|
|
495 |
<ul class="methods-list">
|
|
|
496 |
|
|
|
497 |
<li class="method" id="method-destroy">
|
|
|
498 |
<div class="method-header">
|
|
|
499 |
<h3 class="method-name"><a href="#method-destroy">destroy</a></h3>
|
|
|
500 |
<dl>
|
|
|
501 |
<dt class="method-signature-label">Signature:</dt>
|
|
|
502 |
<dd class="method-signature">.autocomplete( "destroy"
|
|
|
503 |
|
|
|
504 |
|
|
|
505 |
|
|
|
506 |
|
|
|
507 |
|
|
|
508 |
|
|
|
509 |
|
|
|
510 |
)</dd>
|
|
|
511 |
</dl>
|
|
|
512 |
</div>
|
|
|
513 |
<div class="method-description">
|
|
|
514 |
<p>Remove the autocomplete functionality completely. This will return the element back to its pre-init state.</p>
|
|
|
515 |
</div>
|
|
|
516 |
</li>
|
|
|
517 |
|
|
|
518 |
|
|
|
519 |
<li class="method" id="method-disable">
|
|
|
520 |
<div class="method-header">
|
|
|
521 |
<h3 class="method-name"><a href="#method-disable">disable</a></h3>
|
|
|
522 |
<dl>
|
|
|
523 |
<dt class="method-signature-label">Signature:</dt>
|
|
|
524 |
<dd class="method-signature">.autocomplete( "disable"
|
|
|
525 |
|
|
|
526 |
|
|
|
527 |
|
|
|
528 |
|
|
|
529 |
|
|
|
530 |
|
|
|
531 |
|
|
|
532 |
)</dd>
|
|
|
533 |
</dl>
|
|
|
534 |
</div>
|
|
|
535 |
<div class="method-description">
|
|
|
536 |
<p>Disable the autocomplete.</p>
|
|
|
537 |
</div>
|
|
|
538 |
</li>
|
|
|
539 |
|
|
|
540 |
|
|
|
541 |
<li class="method" id="method-enable">
|
|
|
542 |
<div class="method-header">
|
|
|
543 |
<h3 class="method-name"><a href="#method-enable">enable</a></h3>
|
|
|
544 |
<dl>
|
|
|
545 |
<dt class="method-signature-label">Signature:</dt>
|
|
|
546 |
<dd class="method-signature">.autocomplete( "enable"
|
|
|
547 |
|
|
|
548 |
|
|
|
549 |
|
|
|
550 |
|
|
|
551 |
|
|
|
552 |
|
|
|
553 |
|
|
|
554 |
)</dd>
|
|
|
555 |
</dl>
|
|
|
556 |
</div>
|
|
|
557 |
<div class="method-description">
|
|
|
558 |
<p>Enable the autocomplete.</p>
|
|
|
559 |
</div>
|
|
|
560 |
</li>
|
|
|
561 |
|
|
|
562 |
|
|
|
563 |
<li class="method" id="method-option">
|
|
|
564 |
<div class="method-header">
|
|
|
565 |
<h3 class="method-name"><a href="#method-option">option</a></h3>
|
|
|
566 |
<dl>
|
|
|
567 |
<dt class="method-signature-label">Signature:</dt>
|
|
|
568 |
<dd class="method-signature">.autocomplete( "option"
|
|
|
569 |
|
|
|
570 |
, optionName
|
|
|
571 |
|
|
|
572 |
, <span class="optional">[</span>value<span class="optional">] </span>
|
|
|
573 |
|
|
|
574 |
|
|
|
575 |
|
|
|
576 |
)</dd>
|
|
|
577 |
</dl>
|
|
|
578 |
</div>
|
|
|
579 |
<div class="method-description">
|
|
|
580 |
<p>Get or set any autocomplete option. If no value is specified, will act as a getter.</p>
|
|
|
581 |
</div>
|
|
|
582 |
</li>
|
|
|
583 |
|
|
|
584 |
|
|
|
585 |
<li class="method" id="method-option">
|
|
|
586 |
<div class="method-header">
|
|
|
587 |
<h3 class="method-name"><a href="#method-option">option</a></h3>
|
|
|
588 |
<dl>
|
|
|
589 |
<dt class="method-signature-label">Signature:</dt>
|
|
|
590 |
<dd class="method-signature">.autocomplete( "option"
|
|
|
591 |
|
|
|
592 |
, options
|
|
|
593 |
|
|
|
594 |
|
|
|
595 |
|
|
|
596 |
|
|
|
597 |
|
|
|
598 |
)</dd>
|
|
|
599 |
</dl>
|
|
|
600 |
</div>
|
|
|
601 |
<div class="method-description">
|
|
|
602 |
<p>Set multiple autocomplete options at once by providing an options object.</p>
|
|
|
603 |
</div>
|
|
|
604 |
</li>
|
|
|
605 |
|
|
|
606 |
|
|
|
607 |
<li class="method" id="method-widget">
|
|
|
608 |
<div class="method-header">
|
|
|
609 |
<h3 class="method-name"><a href="#method-widget">widget</a></h3>
|
|
|
610 |
<dl>
|
|
|
611 |
<dt class="method-signature-label">Signature:</dt>
|
|
|
612 |
<dd class="method-signature">.autocomplete( "widget"
|
|
|
613 |
|
|
|
614 |
|
|
|
615 |
|
|
|
616 |
|
|
|
617 |
|
|
|
618 |
|
|
|
619 |
|
|
|
620 |
)</dd>
|
|
|
621 |
</dl>
|
|
|
622 |
</div>
|
|
|
623 |
<div class="method-description">
|
|
|
624 |
<p>Returns the .ui-autocomplete element.</p>
|
|
|
625 |
</div>
|
|
|
626 |
</li>
|
|
|
627 |
|
|
|
628 |
|
|
|
629 |
<li class="method" id="method-search">
|
|
|
630 |
<div class="method-header">
|
|
|
631 |
<h3 class="method-name"><a href="#method-search">search</a></h3>
|
|
|
632 |
<dl>
|
|
|
633 |
<dt class="method-signature-label">Signature:</dt>
|
|
|
634 |
<dd class="method-signature">.autocomplete( "search"
|
|
|
635 |
|
|
|
636 |
, <span class="optional">[</span>value<span class="optional">] </span>
|
|
|
637 |
|
|
|
638 |
|
|
|
639 |
|
|
|
640 |
|
|
|
641 |
|
|
|
642 |
)</dd>
|
|
|
643 |
</dl>
|
|
|
644 |
</div>
|
|
|
645 |
<div class="method-description">
|
|
|
646 |
<p>Triggers a search event, which, when data is available, then will display the suggestions; can be used by a selectbox-like button to open the suggestions when clicked. If no value argument is specified, the current input's value is used. Can be called with an empty string and minLength: 0 to display all items.</p>
|
|
|
647 |
</div>
|
|
|
648 |
</li>
|
|
|
649 |
|
|
|
650 |
|
|
|
651 |
<li class="method" id="method-close">
|
|
|
652 |
<div class="method-header">
|
|
|
653 |
<h3 class="method-name"><a href="#method-close">close</a></h3>
|
|
|
654 |
<dl>
|
|
|
655 |
<dt class="method-signature-label">Signature:</dt>
|
|
|
656 |
<dd class="method-signature">.autocomplete( "close"
|
|
|
657 |
|
|
|
658 |
|
|
|
659 |
|
|
|
660 |
|
|
|
661 |
|
|
|
662 |
|
|
|
663 |
|
|
|
664 |
)</dd>
|
|
|
665 |
</dl>
|
|
|
666 |
</div>
|
|
|
667 |
<div class="method-description">
|
|
|
668 |
<p>Close the Autocomplete menu. Useful in combination with the search method, to close the open menu.</p>
|
|
|
669 |
</div>
|
|
|
670 |
</li>
|
|
|
671 |
|
|
|
672 |
</ul>
|
|
|
673 |
</div>
|
|
|
674 |
<div id="theming">
|
|
|
675 |
<h2 class="top-header">Theming</h2>
|
|
|
676 |
<p>The jQuery UI Autocomplete plugin uses the jQuery UI CSS Framework to style its look and feel, including colors and background textures. We recommend using the ThemeRoller tool to create and download custom themes that are easy to build and maintain.
|
|
|
677 |
</p>
|
|
|
678 |
<p>If a deeper level of customization is needed, there are widget-specific classes referenced within the jquery.ui.autocomplete.css stylesheet that can be modified. These classes are highlighed in bold below.
|
|
|
679 |
</p>
|
|
|
680 |
|
|
|
681 |
<h3>Sample markup with jQuery UI CSS Framework classes</h3>
|
|
|
682 |
<input class="ui-autocomplete-input"/><br />
|
|
|
683 |
<ul class="ui-autocomplete ui-menu ui-widget ui-widget-content ui-corner-all"><br />
|
|
|
684 |
<li class="ui-menu-item"><br />
|
|
|
685 |
<a class="ui-corner-all">item 1</a><br />
|
|
|
686 |
</li><br />
|
|
|
687 |
<li class="ui-menu-item"><br />
|
|
|
688 |
<a class="ui-corner-all">item 2</a><br />
|
|
|
689 |
</li><br />
|
|
|
690 |
<li class="ui-menu-item"><br />
|
|
|
691 |
<a class="ui-corner-all">item 3</a><br />
|
|
|
692 |
</li><br />
|
|
|
693 |
</ul>
|
|
|
694 |
<p class="theme-note">
|
|
|
695 |
<strong>
|
|
|
696 |
Note: This is a sample of markup generated by the autocomplete plugin, not markup you should use to create a autocomplete. The only markup needed for that is <input/>.
|
|
|
697 |
</strong>
|
|
|
698 |
</p>
|
|
|
699 |
|
|
|
700 |
</div>
|
|
|
701 |
</div>
|
|
|
702 |
|
|
|
703 |
</p><!--
|
|
|
704 |
Pre-expand include size: 29839 bytes
|
|
|
705 |
Post-expand include size: 47753 bytes
|
|
|
706 |
Template argument size: 26499 bytes
|
|
|
707 |
Maximum: 2097152 bytes
|
|
|
708 |
-->
|
|
|
709 |
|
|
|
710 |
<!-- Saved in parser cache with key jqdocs_docs:pcache:idhash:3766-1!1!0!!en!2 and timestamp 20100909204121 -->
|