Multiple autostart in the input file based on category and criteria

I need multiple inputs with multiple autoruns during the search. The search string consists of a category, optional criteria, and values.

Example: Category.Criteria

I tried using jquery with autocomplete, the first level for the autosuggest category works fine as soon as the user selects the category and types in "." . We need to show the Criterias configured for this category.

The second set of automatic offers does not appear immediately when the user selects a category and types "." , but appears as soon as we focus from the input area and return.

Hers is the code https://jsfiddle.net/krishnanpb/gh32nad6/1/

Steps: 1. Select a category, then enter "." , Move out of the input area and reorient the second set of sentences.

$(document).ready(function() { BindControls(); }); function BindControls() { var Categories = [ "Customer", "Equipment", "Link", "Location", "Network", "Service", "Termination"]; $('#tags').autocomplete({ source: Categories, minLength: 0, scroll: true }).focus(function() { $(this).autocomplete("search", ""); }); $('#tags').bind('keypress', function(e) { var code = (e.keyCode ? e.keyCode : e.which); if(code == 46) { console.log(". pressed"); var Criteria = [ "name", "id"]; } $( "#tags" ).autocomplete({ source: Criteria }); }); } 

html:

Tags:

+5
source share
1 answer

You must use the KeyUp event. I also made him re-focus on the input after changing the source.

 $( "#tags" ).keyup(function( event ) { if(event.which == 190) { console.log(". pressed"); var Criteria = ["name", "id"]; $('#tags').autocomplete({ source: Criteria }); $('#tags').focus(); } }); 
0
source

Source: https://habr.com/ru/post/1235767/


All Articles