You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Can someone help me? I need to make a filtering of suggestion but i'm using serviceUrl to get the data with json. In the example of this page the filtering works great just with local data.
I have added this:
lookupFilter: function (suggestion, originalQuery, queryLowerCase) {
var re = new RegExp('\b' + $.Autocomplete.utils.escapeRegExChars(queryLowerCase), 'gi');
return re.test(suggestion.value);
},
But still not working (is not filtering). This is the entire code:
// Initialize ajax autocomplete:
$('#autocomplete-ajax').autocomplete({
serviceUrl: '/Handler.ashx',
lookupFilter: function (suggestion, originalQuery, queryLowerCase) {
var re = new RegExp('\\b' + $.Autocomplete.utils.escapeRegExChars(queryLowerCase), 'gi');
return re.test(suggestion.value);
},
onSelect: function (suggestion) {
$('#selction-ajax').html('You selected: ' + suggestion.value + ', ' + suggestion.data);
},
onHint: function (hint) {
$('#autocomplete-ajax-x').val(hint);
},
onInvalidateSelection: function () {
$('#selction-ajax').html('You selected: none');
}
});
The text was updated successfully, but these errors were encountered:
You are right and I understand.
Thank you very much.
Well I will use "context" variable to get the suggestion word.
The solution for me is something like this:
Public Sub ProcessRequest(ByVal context As HttpContext) Implements IHttpHandler.ProcessRequest
Dim prefix As String = context.Request.QueryString("query")
Dim DevelopersList As String = ""
Dim MyConn As SQLiteConnection = New SQLiteConnection("Data Source=database.db;Version=3;")
Dim MyComm As SQLiteCommand = New SQLiteCommand("SELECT * FROM people_list WHERE Name LIKE '%" & prefix & "%'", MyConn)
MyConn.Open()
Dim dr As SQLiteDataReader = MyComm.ExecuteReader
While dr.Read
If dr.Item("ID") IsNot DBNull.Value Then
DevelopersList += "{ ""value"": """ & dr.Item("Name") & """, ""data"": """ & dr.Item("ID") & """ },"
End If
End While
MyConn.Close()
DevelopersList = DevelopersList.TrimEnd(",", "")
'Cargamos las Javascripts tradicionales
Dim DevelopersListJS As String = String.Empty
DevelopersListJS += "{ ""query"": ""Unit"", ""suggestions"": ["
DevelopersListJS += DevelopersList
DevelopersListJS += "] }"
context.Response.ContentType = "text/plain"
context.Response.Write(DevelopersListJS)
End Sub
Hi!
I have added this:
lookupFilter: function (suggestion, originalQuery, queryLowerCase) {
var re = new RegExp('\b' + $.Autocomplete.utils.escapeRegExChars(queryLowerCase), 'gi');
return re.test(suggestion.value);
},
But still not working (is not filtering). This is the entire code:
The text was updated successfully, but these errors were encountered: