From 6ca34276bdbf49cb4a53134f88c575ee81d96839 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 19 Jul 2021 01:17:32 +0200 Subject: [PATCH] refactor --- .../InvenTree/static/script/inventree/inventree.js | 10 ++++++++++ InvenTree/templates/base.html | 9 --------- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/InvenTree/InvenTree/static/script/inventree/inventree.js b/InvenTree/InvenTree/static/script/inventree/inventree.js index 79e02d7da5..70cb3b292f 100644 --- a/InvenTree/InvenTree/static/script/inventree/inventree.js +++ b/InvenTree/InvenTree/static/script/inventree/inventree.js @@ -80,6 +80,16 @@ function inventreeDocReady() { attachClipboard('.clip-btn'); attachClipboard('.clip-btn', 'modal-about'); // modals attachClipboard('.clip-btn-version', 'modal-about', 'about-copy-text'); // version-text + + // Add autocomplete to the search-bar + $("#search-bar" ).autocomplete({ + source: "{% url 'search-api' %}", + minLength: 2, + classes: {'ui-autocomplete': 'dropdown-menu'}, + select: function( event, ui ) { + window.location = '/part/' + ui.item.id + '/'; + } + }); } function isFileTransfer(transfer) { diff --git a/InvenTree/templates/base.html b/InvenTree/templates/base.html index e887032f66..9d4eaa5142 100644 --- a/InvenTree/templates/base.html +++ b/InvenTree/templates/base.html @@ -191,15 +191,6 @@ $(document).ready(function () { {% endif %} moment.locale('{{request.LANGUAGE_CODE}}'); - - $("#search-bar" ).autocomplete({ - source: "{% url 'search-api' %}", - minLength: 2, - classes: {'ui-autocomplete': 'dropdown-menu'}, - select: function( event, ui ) { - window.location = '/part/' + ui.item.id + '/'; - } - }); });