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 ( work (request, response) {$ .ajax ({Url : "Availabletags.json", data type: "Jason", data: {word: request.term}, success: function (data) {response ($ .map (data.stuff, function (item) {return {label: Item.label, value: item.value}}}))}}}}}, minnumber: 2, select: function (event, y } {$ (Event.target) .val (ui.item.label); Window.location = ui.item.value; return back;;}})}}}

Edit: - This is Jason File

  {"stuff": [{"label": "dragon", "value": "example .com"}, {"label": "Test", "value": "eg2.com"}]}  

successful editing code

  & 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

Popular posts from this blog

java - org.apache.http.ProtocolException: Target host is not specified -

java - Gradle dependencies: compile project by relative path -

ruby on rails - Object doesn't support #inspect when used with .include -