I want to program a search contract in my windows 8 app. basically everythings just works as it should, except the suggestion list. Always when i enter the function, where i should add my suggestions i get the runtime error 0x8000000e
I just copy pasted the code from the examples, with the only difference, that i load my data from the database.
appModel.Search.SearchPane.getForCurrentView().onsuggestionsrequested = function (eventObject) {
var queryText = eventObject.queryText, suggestionRequest = eventObject.request;
var query = queryText.toLowerCase();
var maxNumberOfSuggestions = 5;
mkData.getWords(eventObject.queryText, maxNumberOfSuggestions, function (suggestionList) {
for (var i = 0, len = suggestionList.length; i < len; i++) {
if (suggestionList[i].substr(0, query.length).toLowerCase() === query) {
suggestionRequest.searchSuggestionCollection.appendQuerySuggestion(suggestionList[i]);
if (suggestionRequest.searchSuggestionCollection.size === maxNumberOfSuggestions) {
break;
}
}
}
});
if (suggestionRequest.searchSuggestionCollection.size > 0) {
WinJS.log && WinJS.log("Suggestions provided for query: " + queryText, "sample", "status");
} else {
WinJS.log && WinJS.log("No suggestions provided for query: " + queryText, "sample", "status");
}
};
if i exchange the Ajax-Call with an static array of suggestions, it works :( in the suggestion list are good words.
I already found solutions for this, but only in C#. There the developer must add the await keyword, but in javascript i dont have this.
thanks in advance!
well i solved it now on my own. here the solution. you have to use the Deferral. Its hardly documented :(
appModel.Search.SearchPane.getForCurrentView().onsuggestionsrequested = function (eventObject) {
var queryText = eventObject.queryText, suggestionRequest = eventObject.request;
var maxNumberOfSuggestions = 5;
var deferral = eventObject.request.getDeferral();
mkData.getWords(queryText, maxNumberOfSuggestions, function (suggestionList) {
suggestionRequest.searchSuggestionCollection.appendQuerySuggestions(suggestionList);
deferral.complete();
});
if (suggestionRequest.searchSuggestionCollection.size > 0) {
WinJS.log && WinJS.log("Suggestions provided for query: " + queryText, "sample", "status");
} else {
WinJS.log && WinJS.log("No suggestions provided for query: " + queryText, "sample", "status");
}
};
User contributions licensed under CC BY-SA 3.0