Hi guys!
I've used jquery-ui-1.8.20's autocomplete and it used to work fine.
Then, I changed it to jquery-ui-1.9.1, and it failed.
I'm using not only autocomplete of jquery-ui-1.9.1, but other features too, like dialog, so I don't want to have 2 versions of jquery-ui in my project.
Here is my code:
- $("#searchBox").ready(function () {
- $('input[id$="txtPredictiveSearchBox"]').autocomplete({
- minLength: 1,
- delay: 200,
- autoFocus: true,
- highlight: true,
- source: function (request, response) {
- var typeOfSearch = $(this.element.context).parent().parent().find('input:checked').val()
- == "GetStockSearchSuggestions" ? 0 : 1;
- var data = { searchText: request.term, count: 5, contextKey: typeOfSearch };
- $.ajax({
- type: "POST",
- url: "/srv/AutoSuggest.aspx/GetSuggestions",
- contentType: "application/json; charset=utf-8",
- dataType: "json",
- data: JSON.stringify(data),
- delay: 200,
- processdata: true,
- success: function (data) {
- response(data.d);
- },
- error: function (er) {
- response("An error occur tryig load autocomplete data. See the console for mor info.");
- console.log(er.responseText);
- }
- });
- },
- select: function (event, ui) {
- window.location.assign(ui.item.href);
- },
- open: function (event, ui) {
- $(this).autocomplete("widget")
- .find("ui-menu-item-alternate")
- .removeClass("ui-menu-item-alternate")
- .end()
- .find("li.ui-menu-item:odd a")
- .addClass("ui-menu-item-alternate");
- },
- focus: function (event, ui) { },
- close: function () { }
- });
- });
Where
/srv/AutoSuggest.aspx/GetSuggestions is a
WebMethod that returns an array of SearchItem:
- public struct SearchItem
- {
- public string value;
- public string text;
- public string href;
- }
On debug mode I can see expected result in success function's data.d prop, but
generate nothing (doesn't show any data.).
This code used to work with jquery-ui-1.8.20. I haven't change anything in this code. I've changed only a version of jquery-ui.
Any ideas?
Thanks in advance!
Gev