comparison jquery-ui/development-bundle/docs/autocomplete.html @ 0:b2e4605f20b2

beta version
author dwinter
date Thu, 30 Jun 2011 09:07:49 +0200
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:b2e4605f20b2
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). It's important when providing a custom source callback to handle errors during the request. You must always call the response callback even if you encounter an error. This ensures that the widget always has the correct state.</li>
30 </ul>
31 <p>The label is always treated as text, if you want the label to be treated as html you can use <a href="https://github.com/scottgonzalez/jquery-ui-extensions/blob/master/autocomplete/jquery.ui.autocomplete.html.js" class="external text" title="https://github.com/scottgonzalez/jquery-ui-extensions/blob/master/autocomplete/jquery.ui.autocomplete.html.js">Scott González' html extension</a>. 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>$(&quot;input#autocomplete&quot;).autocomplete({
49 source: [&quot;c++&quot;, &quot;java&quot;, &quot;php&quot;, &quot;coldfusion&quot;, &quot;javascript&quot;, &quot;asp&quot;, &quot;ruby&quot;]
50 });
51 </pre>
52 <p></div><div id="source" class="tabs-container">
53 </p>
54 <pre>&lt;!DOCTYPE html&gt;
55 &lt;html&gt;
56 &lt;head&gt;
57 &lt;link href=&quot;http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot;/&gt;
58 &lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js&quot;&gt;&lt;/script&gt;
59 &lt;script src=&quot;http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js&quot;&gt;&lt;/script&gt;
60
61 &lt;script&gt;
62 $(document).ready(function() {
63 $(&quot;input#autocomplete&quot;).autocomplete({
64 source: [&quot;c++&quot;, &quot;java&quot;, &quot;php&quot;, &quot;coldfusion&quot;, &quot;javascript&quot;, &quot;asp&quot;, &quot;ruby&quot;]
65 });
66 });
67 &lt;/script&gt;
68 &lt;/head&gt;
69 &lt;body style="font-size:62.5%;"&gt;
70
71 &lt;input id=&quot;autocomplete&quot; /&gt;
72
73 &lt;/body&gt;
74 &lt;/html&gt;
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-appendTo">
127 <div class="option-header">
128 <h3 class="option-name"><a href="#option-appendTo">appendTo</a></h3>
129 <dl>
130 <dt class="option-type-label">Type:</dt>
131 <dd class="option-type">Selector</dd>
132
133 <dt class="option-default-label">Default:</dt>
134 <dd class="option-default">"body"</dd>
135
136 </dl>
137 </div>
138 <div class="option-description">
139 <p>Which element the menu should be appended to.</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>appendTo</code> option specified.
147 </dt>
148 <dd>
149 <pre><code>$( ".selector" ).autocomplete({ appendTo: "#someElem" });</code></pre>
150 </dd>
151
152
153 <dt>
154 Get or set the <code>appendTo</code> option, after init.
155 </dt>
156 <dd>
157 <pre><code>//getter
158 var appendTo = $( ".selector" ).autocomplete( "option", "appendTo" );
159 //setter
160 $( ".selector" ).autocomplete( "option", "appendTo", "#someElem" );</code></pre>
161 </dd>
162
163 </dl>
164 </div>
165 </li>
166
167
168 <li class="option" id="option-delay">
169 <div class="option-header">
170 <h3 class="option-name"><a href="#option-delay">delay</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">300</dd>
177
178 </dl>
179 </div>
180 <div class="option-description">
181 <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>
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>delay</code> option specified.
189 </dt>
190 <dd>
191 <pre><code>$( ".selector" ).autocomplete({ delay: 0 });</code></pre>
192 </dd>
193
194
195 <dt>
196 Get or set the <code>delay</code> option, after init.
197 </dt>
198 <dd>
199 <pre><code>//getter
200 var delay = $( ".selector" ).autocomplete( "option", "delay" );
201 //setter
202 $( ".selector" ).autocomplete( "option", "delay", 0 );</code></pre>
203 </dd>
204
205 </dl>
206 </div>
207 </li>
208
209
210 <li class="option" id="option-minLength">
211 <div class="option-header">
212 <h3 class="option-name"><a href="#option-minLength">minLength</a></h3>
213 <dl>
214 <dt class="option-type-label">Type:</dt>
215 <dd class="option-type">Integer</dd>
216
217 <dt class="option-default-label">Default:</dt>
218 <dd class="option-default">1</dd>
219
220 </dl>
221 </div>
222 <div class="option-description">
223 <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>
224 </div>
225 <div class="option-examples">
226 <h4>Code examples</h4>
227 <dl class="option-examples-list">
228
229 <dt>
230 Initialize a autocomplete with the <code>minLength</code> option specified.
231 </dt>
232 <dd>
233 <pre><code>$( ".selector" ).autocomplete({ minLength: 0 });</code></pre>
234 </dd>
235
236
237 <dt>
238 Get or set the <code>minLength</code> option, after init.
239 </dt>
240 <dd>
241 <pre><code>//getter
242 var minLength = $( ".selector" ).autocomplete( "option", "minLength" );
243 //setter
244 $( ".selector" ).autocomplete( "option", "minLength", 0 );</code></pre>
245 </dd>
246
247 </dl>
248 </div>
249 </li>
250
251
252 <li class="option" id="option-position">
253 <div class="option-header">
254 <h3 class="option-name"><a href="#option-position">position</a></h3>
255 <dl>
256 <dt class="option-type-label">Type:</dt>
257 <dd class="option-type">Object</dd>
258
259 <dt class="option-default-label">Default:</dt>
260 <dd class="option-default">{ my: &quot;left top&quot;, at: &quot;left bottom&quot;, collision: &quot;none&quot; }</dd>
261
262 </dl>
263 </div>
264 <div class="option-description">
265 <p>Identifies the position of the Autocomplete widget in relation to the associated input element. The "of" option defaults to the input element, but you can specify another element to position against. You can refer to the <a href="http://docs.jquery.com/UI/Position" class="external text" title="http://docs.jquery.com/UI/Position">jQuery UI Position</a> utility for more details about the various options.</p>
266 </div>
267 <div class="option-examples">
268 <h4>Code examples</h4>
269 <dl class="option-examples-list">
270
271 <dt>
272 Initialize a autocomplete with the <code>position</code> option specified.
273 </dt>
274 <dd>
275 <pre><code>$( ".selector" ).autocomplete({ position: { my : &quot;right top&quot;, at: &quot;right bottom&quot; } });</code></pre>
276 </dd>
277
278
279 <dt>
280 Get or set the <code>position</code> option, after init.
281 </dt>
282 <dd>
283 <pre><code>//getter
284 var position = $( ".selector" ).autocomplete( "option", "position" );
285 //setter
286 $( ".selector" ).autocomplete( "option", "position", { my : &quot;right top&quot;, at: &quot;right bottom&quot; } );</code></pre>
287 </dd>
288
289 </dl>
290 </div>
291 </li>
292
293
294 <li class="option" id="option-source">
295 <div class="option-header">
296 <h3 class="option-name"><a href="#option-source">source</a></h3>
297 <dl>
298 <dt class="option-type-label">Type:</dt>
299 <dd class="option-type">String, Array, Callback</dd>
300
301 <dt class="option-default-label">Default:</dt>
302 <dd class="option-default">none, must be specified</dd>
303
304 </dl>
305 </div>
306 <div class="option-description">
307 <p>Defines the data to use, must be specified. See Overview section for more details, and look at the various demos.
308 </p>
309 </div>
310 <div class="option-examples">
311 <h4>Code examples</h4>
312 <dl class="option-examples-list">
313
314 <dt>
315 Initialize a autocomplete with the <code>source</code> option specified.
316 </dt>
317 <dd>
318 <pre><code>$( ".selector" ).autocomplete({ source: [&quot;c++&quot;, &quot;java&quot;, &quot;php&quot;, &quot;coldfusion&quot;, &quot;javascript&quot;, &quot;asp&quot;, &quot;ruby&quot;] });</code></pre>
319 </dd>
320
321
322 <dt>
323 Get or set the <code>source</code> option, after init.
324 </dt>
325 <dd>
326 <pre><code>//getter
327 var source = $( ".selector" ).autocomplete( "option", "source" );
328 //setter
329 $( ".selector" ).autocomplete( "option", "source", [&quot;c++&quot;, &quot;java&quot;, &quot;php&quot;, &quot;coldfusion&quot;, &quot;javascript&quot;, &quot;asp&quot;, &quot;ruby&quot;] );</code></pre>
330 </dd>
331
332 </dl>
333 </div>
334 </li>
335
336 </ul>
337 </div>
338 <div id="events">
339 <h2 class="top-header">Events</h2>
340 <ul class="events-list">
341
342 <li class="event" id="event-create">
343 <div class="event-header">
344 <h3 class="event-name"><a href="#event-create">create</a></h3>
345 <dl>
346 <dt class="event-type-label">Type:</dt>
347 <dd class="event-type">autocompletecreate</dd>
348 </dl>
349 </div>
350 <div class="event-description">
351 <p>This event is triggered when autocomplete is created.</p>
352 </div>
353 <div class="event-examples">
354 <h4>Code examples</h4>
355 <dl class="event-examples-list">
356
357 <dt>
358 Supply a callback function to handle the <code>create</code> event as an init option.
359 </dt>
360 <dd>
361 <pre><code>$( &quot;.selector&quot; ).autocomplete({
362 create: function(event, ui) { ... }
363 });</code></pre>
364 </dd>
365
366
367 <dt>
368 Bind to the <code>create</code> event by type: <code>autocompletecreate</code>.
369 </dt>
370 <dd>
371 <pre><code>$( &quot;.selector&quot; ).bind( &quot;autocompletecreate&quot;, function(event, ui) {
372 ...
373 });</code></pre>
374 </dd>
375
376 </dl>
377 </div>
378 </li>
379
380
381 <li class="event" id="event-search">
382 <div class="event-header">
383 <h3 class="event-name"><a href="#event-search">search</a></h3>
384 <dl>
385 <dt class="event-type-label">Type:</dt>
386 <dd class="event-type">autocompletesearch</dd>
387 </dl>
388 </div>
389 <div class="event-description">
390 <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>
391 </div>
392 <div class="event-examples">
393 <h4>Code examples</h4>
394 <dl class="event-examples-list">
395
396 <dt>
397 Supply a callback function to handle the <code>search</code> event as an init option.
398 </dt>
399 <dd>
400 <pre><code>$( &quot;.selector&quot; ).autocomplete({
401 search: function(event, ui) { ... }
402 });</code></pre>
403 </dd>
404
405
406 <dt>
407 Bind to the <code>search</code> event by type: <code>autocompletesearch</code>.
408 </dt>
409 <dd>
410 <pre><code>$( &quot;.selector&quot; ).bind( &quot;autocompletesearch&quot;, function(event, ui) {
411 ...
412 });</code></pre>
413 </dd>
414
415 </dl>
416 </div>
417 </li>
418
419
420 <li class="event" id="event-open">
421 <div class="event-header">
422 <h3 class="event-name"><a href="#event-open">open</a></h3>
423 <dl>
424 <dt class="event-type-label">Type:</dt>
425 <dd class="event-type">autocompleteopen</dd>
426 </dl>
427 </div>
428 <div class="event-description">
429 <p>Triggered when the suggestion menu is opened.</p>
430 </div>
431 <div class="event-examples">
432 <h4>Code examples</h4>
433 <dl class="event-examples-list">
434
435 <dt>
436 Supply a callback function to handle the <code>open</code> event as an init option.
437 </dt>
438 <dd>
439 <pre><code>$( &quot;.selector&quot; ).autocomplete({
440 open: function(event, ui) { ... }
441 });</code></pre>
442 </dd>
443
444
445 <dt>
446 Bind to the <code>open</code> event by type: <code>autocompleteopen</code>.
447 </dt>
448 <dd>
449 <pre><code>$( &quot;.selector&quot; ).bind( &quot;autocompleteopen&quot;, function(event, ui) {
450 ...
451 });</code></pre>
452 </dd>
453
454 </dl>
455 </div>
456 </li>
457
458
459 <li class="event" id="event-focus">
460 <div class="event-header">
461 <h3 class="event-name"><a href="#event-focus">focus</a></h3>
462 <dl>
463 <dt class="event-type-label">Type:</dt>
464 <dd class="event-type">autocompletefocus</dd>
465 </dl>
466 </div>
467 <div class="event-description">
468 <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>
469 </div>
470 <div class="event-examples">
471 <h4>Code examples</h4>
472 <dl class="event-examples-list">
473
474 <dt>
475 Supply a callback function to handle the <code>focus</code> event as an init option.
476 </dt>
477 <dd>
478 <pre><code>$( &quot;.selector&quot; ).autocomplete({
479 focus: function(event, ui) { ... }
480 });</code></pre>
481 </dd>
482
483
484 <dt>
485 Bind to the <code>focus</code> event by type: <code>autocompletefocus</code>.
486 </dt>
487 <dd>
488 <pre><code>$( &quot;.selector&quot; ).bind( &quot;autocompletefocus&quot;, function(event, ui) {
489 ...
490 });</code></pre>
491 </dd>
492
493 </dl>
494 </div>
495 </li>
496
497
498 <li class="event" id="event-select">
499 <div class="event-header">
500 <h3 class="event-name"><a href="#event-select">select</a></h3>
501 <dl>
502 <dt class="event-type-label">Type:</dt>
503 <dd class="event-type">autocompleteselect</dd>
504 </dl>
505 </div>
506 <div class="event-description">
507 <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>
508 </div>
509 <div class="event-examples">
510 <h4>Code examples</h4>
511 <dl class="event-examples-list">
512
513 <dt>
514 Supply a callback function to handle the <code>select</code> event as an init option.
515 </dt>
516 <dd>
517 <pre><code>$( &quot;.selector&quot; ).autocomplete({
518 select: function(event, ui) { ... }
519 });</code></pre>
520 </dd>
521
522
523 <dt>
524 Bind to the <code>select</code> event by type: <code>autocompleteselect</code>.
525 </dt>
526 <dd>
527 <pre><code>$( &quot;.selector&quot; ).bind( &quot;autocompleteselect&quot;, function(event, ui) {
528 ...
529 });</code></pre>
530 </dd>
531
532 </dl>
533 </div>
534 </li>
535
536
537 <li class="event" id="event-close">
538 <div class="event-header">
539 <h3 class="event-name"><a href="#event-close">close</a></h3>
540 <dl>
541 <dt class="event-type-label">Type:</dt>
542 <dd class="event-type">autocompleteclose</dd>
543 </dl>
544 </div>
545 <div class="event-description">
546 <p>When the list is hidden - doesn't have to occur together with a change.</p>
547 </div>
548 <div class="event-examples">
549 <h4>Code examples</h4>
550 <dl class="event-examples-list">
551
552 <dt>
553 Supply a callback function to handle the <code>close</code> event as an init option.
554 </dt>
555 <dd>
556 <pre><code>$( &quot;.selector&quot; ).autocomplete({
557 close: function(event, ui) { ... }
558 });</code></pre>
559 </dd>
560
561
562 <dt>
563 Bind to the <code>close</code> event by type: <code>autocompleteclose</code>.
564 </dt>
565 <dd>
566 <pre><code>$( &quot;.selector&quot; ).bind( &quot;autocompleteclose&quot;, function(event, ui) {
567 ...
568 });</code></pre>
569 </dd>
570
571 </dl>
572 </div>
573 </li>
574
575
576 <li class="event" id="event-change">
577 <div class="event-header">
578 <h3 class="event-name"><a href="#event-change">change</a></h3>
579 <dl>
580 <dt class="event-type-label">Type:</dt>
581 <dd class="event-type">autocompletechange</dd>
582 </dl>
583 </div>
584 <div class="event-description">
585 <p>After an item was selected; ui.item refers to the selected item. Always triggered after the close event.</p>
586 </div>
587 <div class="event-examples">
588 <h4>Code examples</h4>
589 <dl class="event-examples-list">
590
591 <dt>
592 Supply a callback function to handle the <code>change</code> event as an init option.
593 </dt>
594 <dd>
595 <pre><code>$( &quot;.selector&quot; ).autocomplete({
596 change: function(event, ui) { ... }
597 });</code></pre>
598 </dd>
599
600
601 <dt>
602 Bind to the <code>change</code> event by type: <code>autocompletechange</code>.
603 </dt>
604 <dd>
605 <pre><code>$( &quot;.selector&quot; ).bind( &quot;autocompletechange&quot;, function(event, ui) {
606 ...
607 });</code></pre>
608 </dd>
609
610 </dl>
611 </div>
612 </li>
613
614 </ul>
615 </div>
616 <div id="methods">
617 <h2 class="top-header">Methods</h2>
618 <ul class="methods-list">
619
620 <li class="method" id="method-destroy">
621 <div class="method-header">
622 <h3 class="method-name"><a href="#method-destroy">destroy</a></h3>
623 <dl>
624 <dt class="method-signature-label">Signature:</dt>
625 <dd class="method-signature">.autocomplete( "destroy"
626
627
628
629
630
631
632
633 )</dd>
634 </dl>
635 </div>
636 <div class="method-description">
637 <p>Remove the autocomplete functionality completely. This will return the element back to its pre-init state.</p>
638 </div>
639 </li>
640
641
642 <li class="method" id="method-disable">
643 <div class="method-header">
644 <h3 class="method-name"><a href="#method-disable">disable</a></h3>
645 <dl>
646 <dt class="method-signature-label">Signature:</dt>
647 <dd class="method-signature">.autocomplete( "disable"
648
649
650
651
652
653
654
655 )</dd>
656 </dl>
657 </div>
658 <div class="method-description">
659 <p>Disable the autocomplete.</p>
660 </div>
661 </li>
662
663
664 <li class="method" id="method-enable">
665 <div class="method-header">
666 <h3 class="method-name"><a href="#method-enable">enable</a></h3>
667 <dl>
668 <dt class="method-signature-label">Signature:</dt>
669 <dd class="method-signature">.autocomplete( "enable"
670
671
672
673
674
675
676
677 )</dd>
678 </dl>
679 </div>
680 <div class="method-description">
681 <p>Enable the autocomplete.</p>
682 </div>
683 </li>
684
685
686 <li class="method" id="method-option">
687 <div class="method-header">
688 <h3 class="method-name"><a href="#method-option">option</a></h3>
689 <dl>
690 <dt class="method-signature-label">Signature:</dt>
691 <dd class="method-signature">.autocomplete( "option"
692
693 , optionName
694
695 , <span class="optional">[</span>value<span class="optional">] </span>
696
697
698
699 )</dd>
700 </dl>
701 </div>
702 <div class="method-description">
703 <p>Get or set any autocomplete option. If no value is specified, will act as a getter.</p>
704 </div>
705 </li>
706
707
708 <li class="method" id="method-option">
709 <div class="method-header">
710 <h3 class="method-name"><a href="#method-option">option</a></h3>
711 <dl>
712 <dt class="method-signature-label">Signature:</dt>
713 <dd class="method-signature">.autocomplete( "option"
714
715 , options
716
717
718
719
720
721 )</dd>
722 </dl>
723 </div>
724 <div class="method-description">
725 <p>Set multiple autocomplete options at once by providing an options object.</p>
726 </div>
727 </li>
728
729
730 <li class="method" id="method-widget">
731 <div class="method-header">
732 <h3 class="method-name"><a href="#method-widget">widget</a></h3>
733 <dl>
734 <dt class="method-signature-label">Signature:</dt>
735 <dd class="method-signature">.autocomplete( "widget"
736
737
738
739
740
741
742
743 )</dd>
744 </dl>
745 </div>
746 <div class="method-description">
747 <p>Returns the .ui-autocomplete element.</p>
748 </div>
749 </li>
750
751
752 <li class="method" id="method-search">
753 <div class="method-header">
754 <h3 class="method-name"><a href="#method-search">search</a></h3>
755 <dl>
756 <dt class="method-signature-label">Signature:</dt>
757 <dd class="method-signature">.autocomplete( "search"
758
759 , <span class="optional">[</span>value<span class="optional">] </span>
760
761
762
763
764
765 )</dd>
766 </dl>
767 </div>
768 <div class="method-description">
769 <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>
770 </div>
771 </li>
772
773
774 <li class="method" id="method-close">
775 <div class="method-header">
776 <h3 class="method-name"><a href="#method-close">close</a></h3>
777 <dl>
778 <dt class="method-signature-label">Signature:</dt>
779 <dd class="method-signature">.autocomplete( "close"
780
781
782
783
784
785
786
787 )</dd>
788 </dl>
789 </div>
790 <div class="method-description">
791 <p>Close the Autocomplete menu. Useful in combination with the search method, to close the open menu.</p>
792 </div>
793 </li>
794
795 </ul>
796 </div>
797 <div id="theming">
798 <h2 class="top-header">Theming</h2>
799 <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.
800 </p>
801 <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.
802 </p>
803
804 <h3>Sample markup with jQuery UI CSS Framework classes</h3>
805 &lt;input class=&quot;ui-autocomplete-input&quot;/&gt;<br />
806 &lt;ul class=&quot;ui-autocomplete ui-menu ui-widget ui-widget-content ui-corner-all&quot;&gt;<br />
807 &nbsp;&nbsp;&lt;li class=&quot;ui-menu-item&quot;&gt;<br />
808 &nbsp;&nbsp;&nbsp;&nbsp;&lt;a class=&quot;ui-corner-all&quot;&gt;item 1&lt;/a&gt;<br />
809 &nbsp;&nbsp;&lt;/li&gt;<br />
810 &nbsp;&nbsp;&lt;li class=&quot;ui-menu-item&quot;&gt;<br />
811 &nbsp;&nbsp;&nbsp;&nbsp;&lt;a class=&quot;ui-corner-all&quot;&gt;item 2&lt;/a&gt;<br />
812 &nbsp;&nbsp;&lt;/li&gt;<br />
813 &nbsp;&nbsp;&lt;li class=&quot;ui-menu-item&quot;&gt;<br />
814 &nbsp;&nbsp;&nbsp;&nbsp;&lt;a class=&quot;ui-corner-all&quot;&gt;item 3&lt;/a&gt;<br />
815 &nbsp;&nbsp;&lt;/li&gt;<br />
816 &lt;/ul&gt;
817 <p class="theme-note">
818 <strong>
819 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 &lt;input/&gt;.
820 </strong>
821 </p>
822
823 </div>
824 </div>
825
826 </p><!--
827 Pre-expand include size: 34461 bytes
828 Post-expand include size: 58313 bytes
829 Template argument size: 31985 bytes
830 Maximum: 2097152 bytes
831 -->
832
833 <!-- Saved in parser cache with key jqdocs_docs:pcache:idhash:3766-1!1!0!!en!2 and timestamp 20110315194630 -->