autocomplete doesnt support jsonp, handler added
authorMarcin Koziej <marcin@lolownia.org>
Thu, 17 May 2012 13:48:40 +0000 (15:48 +0200)
committerMarcin Koziej <marcin@lolownia.org>
Thu, 17 May 2012 13:48:40 +0000 (15:48 +0200)
apps/wolnelektury_core/static/js/search.js
apps/wolnelektury_core/static/js/widget.js

index 0b8dd39..dc9fac2 100644 (file)
@@ -11,23 +11,11 @@ var __bind = function (self, fn) {
         },
 
        _create: function() {
-            console.log("dataType: " + this.options.dataType);
-            var url = this.element.data('source');
            var opts = { 
                minLength: this.options.minLength,
                select: __bind(this, this.enter),
                focus: function() { return false; },
-               source: function(req, cb) {
-                    $.ajax({url: url,
-                            dataType: "jsonp",
-                            type: "GET",
-                            success: function(data) {
-                                cb(data);
-                            },
-                            error: function() { cb([]); }
-
-                });
-                },
+                source: this.element.data('source'),
            };
 
            this.element.autocomplete($.extend(opts, this.options))
index 48eeb87..0947629 100644 (file)
@@ -60,7 +60,18 @@ scriptUI.onreadystatechange = function() { if (scriptUI.readyState == 'complete'
 
 scriptSearch.onload = function() {
        var s = $('#id_qq');
-       s.search({source: s.attr('data-source'), dataType: "jsonp"});
+        var url = s.attr('data-source');
+        s.search({source: 
+                        function(req, cb) {
+                        $.ajax({url: url,
+                                dataType: "jsonp",
+                                data: { term: req.term },
+                                type: "GET",
+                                success: function(data) { cb(data); },
+                                error: function() { cb([]); }
+                    });
+                        },
+            dataType: "jsonp"});
 }
 scriptSearch.onreadystatechange = function() { if (scriptSearch.readyState == 'complete') { scriptSearch.onload(); } };