/[projects]/misc/horsensspejder-web/jquery/jquery-ui-1.10.3/demos/autocomplete/remote-with-cache.html
ViewVC logotype

Contents of /misc/horsensspejder-web/jquery/jquery-ui-1.10.3/demos/autocomplete/remote-with-cache.html

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2125 - (show annotations) (download) (as text)
Wed Mar 12 19:30:05 2014 UTC (10 years, 2 months ago) by torben
File MIME type: text/html
File size: 1645 byte(s)
initial import
1 <!doctype html>
2 <html lang="en">
3 <head>
4 <meta charset="utf-8">
5 <title>jQuery UI Autocomplete - Remote with caching</title>
6 <link rel="stylesheet" href="../../themes/base/jquery.ui.all.css">
7 <script src="../../jquery-1.9.1.js"></script>
8 <script src="../../ui/jquery.ui.core.js"></script>
9 <script src="../../ui/jquery.ui.widget.js"></script>
10 <script src="../../ui/jquery.ui.position.js"></script>
11 <script src="../../ui/jquery.ui.menu.js"></script>
12 <script src="../../ui/jquery.ui.autocomplete.js"></script>
13 <link rel="stylesheet" href="../demos.css">
14 <style>
15 .ui-autocomplete-loading {
16 background: white url('images/ui-anim_basic_16x16.gif') right center no-repeat;
17 }
18 </style>
19 <script>
20 $(function() {
21 var cache = {};
22 $( "#birds" ).autocomplete({
23 minLength: 2,
24 source: function( request, response ) {
25 var term = request.term;
26 if ( term in cache ) {
27 response( cache[ term ] );
28 return;
29 }
30
31 $.getJSON( "search.php", request, function( data, status, xhr ) {
32 cache[ term ] = data;
33 response( data );
34 });
35 }
36 });
37 });
38 </script>
39 </head>
40 <body>
41
42 <div class="ui-widget">
43 <label for="birds">Birds: </label>
44 <input id="birds">
45 </div>
46
47 <div class="demo-description">
48 <p>The Autocomplete widgets provides suggestions while you type into the field. Here the suggestions are bird names, displayed when at least two characters are entered into the field.</p>
49 <p>Similar to the remote datasource demo, though this adds some local caching to improve performance. The cache here saves just one query, and could be extended to cache multiple values, one for each term.</p>
50 </div>
51 </body>
52 </html>

  ViewVC Help
Powered by ViewVC 1.1.20