From: Marcin Koziej Date: Thu, 17 May 2012 13:48:40 +0000 (+0200) Subject: autocomplete doesnt support jsonp, handler added X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/637f96b139a895372c2e90684858c07fb09a709f?ds=inline;hp=--cc autocomplete doesnt support jsonp, handler added --- 637f96b139a895372c2e90684858c07fb09a709f diff --git a/apps/wolnelektury_core/static/js/search.js b/apps/wolnelektury_core/static/js/search.js index 0b8dd394a..dc9fac202 100644 --- a/apps/wolnelektury_core/static/js/search.js +++ b/apps/wolnelektury_core/static/js/search.js @@ -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)) diff --git a/apps/wolnelektury_core/static/js/widget.js b/apps/wolnelektury_core/static/js/widget.js index 48eeb874d..09476297f 100644 --- a/apps/wolnelektury_core/static/js/widget.js +++ b/apps/wolnelektury_core/static/js/widget.js @@ -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(); } };