[Rt-commit] rt branch, owner-autocomplete, updated. rt-3.8.8-490-g136da43

Thomas Sibley trs at bestpractical.com
Thu Aug 19 22:17:12 EDT 2010


The branch, owner-autocomplete has been updated
       via  136da43bc149c9254a809165c50c07f154e25b2e (commit)
      from  87bb32ce0138a1b88cd8257b83337da092f5703c (commit)

Summary of changes:
 share/html/Elements/SelectOwnerAutocomplete |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

- Log -----------------------------------------------------------------
commit 136da43bc149c9254a809165c50c07f154e25b2e
Author: Thomas Sibley <trs at bestpractical.com>
Date:   Thu Aug 19 22:19:19 2010 -0400

    Add some client-side caching for terms we've already seen

diff --git a/share/html/Elements/SelectOwnerAutocomplete b/share/html/Elements/SelectOwnerAutocomplete
index cd179db..11dd55c 100644
--- a/share/html/Elements/SelectOwnerAutocomplete
+++ b/share/html/Elements/SelectOwnerAutocomplete
@@ -74,8 +74,24 @@ my $query = $m->comp('/Elements/QueryString',
 <input type="text" name="<%$Name%>" id="<%$Name%>" value="<% $value %>" />
 <script type="text/javascript">
     jQuery(function() {
+        var cache = {};
         jQuery("#<% $Name %>").autocomplete({
-            source: "<% RT->Config->Get('WebPath')%>/Helpers/Autocomplete/Owners?<% $query|n %>"
+            source: function(request, response) {
+                if ( request.term in cache ) {
+                    response( cache[ request.term ] );
+                }
+                else {
+                    jQuery.ajax({
+                        url: "<% RT->Config->Get('WebPath')%>/Helpers/Autocomplete/Owners?<% $query|n %>",
+                        dataType: "json",
+                        data: request,
+                        success: function( data ) {
+                            cache[ request.term ] = data;
+                            response( data );
+                        }
+                    });
+                }
+            }
         });
     });
 </script>

-----------------------------------------------------------------------


More information about the Rt-commit mailing list