X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/a778b5b2bd97b5e26d90b668320fad23b6fc8b1a..9b8b01f5d27d66386597a8789d921f3a2c630e09:/wolnelektury/static/js/widgetInit.js diff --git a/wolnelektury/static/js/widgetInit.js b/wolnelektury/static/js/widgetInit.js new file mode 100644 index 000000000..074dbebc1 --- /dev/null +++ b/wolnelektury/static/js/widgetInit.js @@ -0,0 +1,29 @@ + $(function() { + $("#id_q").autocomplete({ + source: function(request, response) { + $.ajax({ + url: "http://www.wolnelektury.pl/katalog/jtags/", + dataType: "jsonp", + data: { + featureClass: "P", + style: "full", + maxRows: 10, + q: request.term + }, + success: function(data) { + response($.map(data.matches, function(item) { + return { + label: item, + value: item + } + })) + }, + }) + }, + minLength: 2, + select: function(event, ui) { + $("#id_q").val(ui.item.value); + $("#wl-form").submit(); + } + }); + });