2
0
mirror of https://github.com/inventree/InvenTree.git synced 2025-06-17 20:45:44 +00:00

Adding search auto-complete #280

This commit is contained in:
2021-07-19 00:46:51 +02:00
parent c71fbf7893
commit 17eee66b95
4 changed files with 30 additions and 2 deletions

View File

@ -191,6 +191,14 @@ $(document).ready(function () {
{% endif %}
moment.locale('{{request.LANGUAGE_CODE}}');
$("#search-bar" ).autocomplete({
source: "{% url 'search-api' %}",
minLength: 2,
select: function( event, ui ) {
window.location = '/part/' + ui.item.id + '/';
}
});
});
</script>

View File

@ -3,7 +3,7 @@
<form class="navbar-form navbar-left" action="{% url 'search' %}" method='post'>
{% csrf_token %}
<div class="form-group">
<input type="text" name='search' class="form-control" placeholder="{% trans 'Search' %}"{% if query_text %} value="{{ query }}"{% endif %}>
<input type="text" name='search' class="form-control" id="search-bar" placeholder="{% trans 'Search' %}"{% if query_text %} value="{{ query }}"{% endif %}>
</div>
<button type="submit" id='search-submit' class="btn btn-default" title='{% trans "Search" %}'>
<span class='fas fa-search'></span>