Anonymous avatar Anonymous committed 454edb5

Using "q" as the default query GET param. Should be easier switching to jQuery.
It seems jQuery Autocomplete can't be customized to use "query" instead of "q".

Comments (0)

Files changed (3)

autocomplete/media/js/yui_autocomplete.js

         autocomplete.resultTypeList = false;
         autocomplete.queryDelay = .5;
         autocomplete.forceSelection = force_selection;
+        autocomplete.generateRequest = function(sQuery) {
+            return "?q="+sQuery;
+        };
 
         var selected_item = {label: null, id: null};
         var hidden = document.getElementById("id_hidden_"+name);

autocomplete/views.py

     def __init__(self):
         self.settings = dict()
 
-    def __call__(self, request, ac_name, query_param='query'):
+    def __call__(self, request, ac_name, query_param='q'):
         if not ac_name in self.settings:
             return self.not_found(request, ac_name)
 

docs/library/views.rst

     consists of a list of *key-label* pairs::
 
         # Request:
-        GET /autocomplete/fruit/?query=red
+        GET /autocomplete/fruit/?q=red
         
         # JSON Response:
         [[9, "Strawberry"], [10, "Cherry"], [11, "Apple"]]
         as views.
 
         The optional argument *query_param* is the name of the GET parameter
-        that should contain the user input. It defaults to ``'query'``.
+        that should contain the user input. It defaults to ``'q'``.
 
         If the Javascript toolkit you're using requires you to use an other
-        value (e.g. ``'q'``) you can customize this param, by passing a
+        value (e.g. ``'query'``) you can customize this param, by passing a
         ``dict`` to the autocomplete view in your URLConf::
 
-            url('^autocomplete/(\w+)$', autocomplete, dict(query_param='q')),
+            url('^autocomplete/(\w+)$', autocomplete, dict(query_param='query')),
 
 
     .. method:: not_found(request, ac_name):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.