javascript - jquery autocomplete 'Disable' show all terms -
Hey nobody can let me out of this problem .... I successfully build the jquier autocomplete function, But my problem is that the autocomplete suggestion shows all available labels showing autocomplete results that do not match the search term. I mean this is showing all the available labels. Is there any solution to show their only matching labels? Here is a Java function. Any help would be appreciated happily thanks ( Edit: - This is Jason File successful editing code
{"stuff": [{"label": "dragon", "value": "example .com"}, {"label": "Test", "value": "eg2.com"}]}
& lt; script & gt; $ (document) ) .ready (function () {$ ("# search-title"). Autocomplete ({source: function (request, response) {$ .ajax ({url: "availabletags.json", data type: "json" success : Work (data) {var sData = data.stuff.filter (function (v) {var re = new RegExp (request.term, "i"); Return re.test (v.label);}); Feedback ($ .map (sData, function (item) {return: {label: item.label, value: item.value}}})}}}})}}, minnane: 2, focus: function (event, UI) ) {This.value = ui.item.label; Event.preventDefault (); // stop the default focus behavior.}, Select: function (Event, UI) {$ (event.target) .val (ui.item label); Window. Place = ui.item.value; Return back ;;}});}); & Lt; / Script & gt;
Here is the change you want to create:
Data type: "JSN", success: work (data) {var sData = data.stuff.filter (function (v) {return v.value.indexOf (request.term)> 1;}); The response ($ .map (sData, function) will be done by { this search value
. label
, in other words, The following is used instead of the label in your JSON for the user's input:
back v.label.indexOf (........ UPDATE To make your search case insensitive, use the following:
var re = new RegExp ( Returns v.value.indexOf (request.term)> instead of -1; re.exe (v.label);
back.
< / P>
Comments
Post a Comment