github
Advanced Search
  • Home
  • Pricing and Signup
  • Explore GitHub
  • Blog
  • Login

jquery / jquery-ui

  • Admin
  • Watch Unwatch
  • Fork
  • Your Fork
  • Pull Request
  • Download Source
    • 553
    • 89
  • Source
  • Commits
  • Network (89)
  • Graphs
  • Tree: e087e7d

click here to add a description

click here to add a homepage

  • Switch Branches (7)
    • bind
    • devpreview
    • formcontrols
    • master
    • menu
    • panel
    • tooltip
  • Switch Tags (18)
    • 1.9m1
    • 1.8rc3
    • 1.8rc2
    • 1.8rc1
    • 1.8b1
    • 1.8a2
    • 1.8a1
    • 1.8.2
    • 1.8.1
    • 1.8
    • 1.7
    • 1.6rc6
    • 1.6rc5
    • 1.6rc3
    • 1.6rc2
    • 1.6
    • 1.5.2
    • 1.5.1
  • Comments
  • Contributors
Sending Request…

The official jQuery user interface library. — Read more

  Cancel

http://jqueryui.com/

  Cancel
  • HTTP
  • Git Read-Only

This URL has Read+Write access

Autocomplete: Changed cache demo to cache all results.

Fixes #5398 - Remote-with-cache demo does not break if (cache.term == 
request.term) but executes another request.
scottgonzalez (author)
Fri Apr 23 09:19:06 -0700 2010
commit  e087e7dee07555f7b78e
tree    512ade389ccd281e8af5
parent  02c32959d9761e56be94
M demos/autocomplete/remote-with-cache.html 33 ••••
Txt demos/autocomplete/remote-with-cache.html
  • View file @ e087e7d
... ...
@@ -12,36 +12,24 @@
12 12
   <link type="text/css" href="../demos.css" rel="stylesheet" />
13 13
   <script type="text/javascript">
14 14
   $(function() {
15  
-    function log(message) {
16  
-      $("<div/>").text(message).prependTo("#log");
17  
-      $("#log").attr("scrollTop", 0);
18  
-    }
19  
-    
20 15
     var cache = {};
21  
-    $("#birds").autocomplete({
  16
+    $( "#birds" ).autocomplete({
  17
+      minLength: 2,
22 18
       source: function(request, response) {
23  
-        if (cache.term == request.term && cache.content) {
24  
-          response(cache.content);
25  
-          return;
26  
-        }
27  
-        if (new RegExp(cache.term).test(request.term) && cache.content && cache.content.length < 13) {
28  
-          response($.ui.autocomplete.filter(cache.content, request.term));
  19
+        if ( request.term in cache ) {
  20
+          response( cache[ request.term ] );
29 21
           return;
30 22
         }
  23
+        
31 24
         $.ajax({
32 25
           url: "search.php",
33 26
           dataType: "json",
34 27
           data: request,
35  
-          success: function(data) {
36  
-            cache.term = request.term;
37  
-            cache.content = data;
38  
-            response(data);
  28
+          success: function( data ) {
  29
+            cache[ request.term ] = data;
  30
+            response( data );
39 31
           }
40 32
         });
41  
-      },
42  
-      minLength: 2,
43  
-      select: function(event, ui) {
44  
-        log(ui.item ? ("Selected: " + ui.item.value + " aka " + ui.item.id) : "Nothing selected, input was " + this.value);
45 33
       }
46 34
     });
47 35
   });
... ...
@@ -56,11 +44,6 @@
56 44
   <input id="birds" />
57 45
 </div>
58 46
 
59  
-<div class="ui-widget" style="margin-top:2em; font-family:Arial">
60  
-  Result:
61  
-  <div id="log" style="height: 200px; width: 300px; overflow: auto;" class="ui-widget-content"></div>
62  
-</div>
63  
-
64 47
 </div><!-- End demo -->
65 48
 
66 49
 <div class="demo-description">

0 notes on commit e087e7d

Please log in to comment.
Blog | Support | Training | Contact | API | Status | Twitter | Help | Security
© 2010 GitHub Inc. All rights reserved. | Terms of Service | Privacy Policy
Powered by the Dedicated Servers and
Cloud Computing of Rackspace Hosting®
Dedicated Server