我遇到WinJS问题。我没有遇到问题。我想用数据项填充(并且我这样做)autosuggestbox。之后,通常,它必须显示autosuggestbox。但是WinJS没有列出清单。
(function () {
"use strict";
WinJS.UI.Pages.define("/pages/home/home.html", {
// This function is called whenever a user navigates to this page. It
// populates the page elements with the app’s data.
ready: function (element, options) {
var searchBox1 = document.querySelector("#station1");
var searchBox2 = document.querySelector("#station2");
searchBox1.addEventListener("suggestionsrequested", GuiEvents.stationRequest);
searchBox1.addEventListener("querysubmitted", Main.stationSubmittedHandler);
searchBox2.addEventListener("suggestionsrequested", GuiEvents.stationRequest);
searchBox2.addEventListener("querysubmitted", Main.stationSubmittedHandler);
WinJS.UI.processAll();
}
});
})();
事件处理程序:
static stationRequest(event: CustomEvent) {
var query = <string>event.detail.queryText;
var suggestionCollection = event.detail.searchSuggestionCollection;
var callback = function (response) {
event.detail.setPromise(WinJS.Promise.then(null, function () {
var _locations: Array<Object> = JSON.parse(response.responseText).LocationList.StopLocation;
$("#response").text(JSON.stringify(_locations));
_locations.forEach(function (obj: ILocation, index, _loc) {
suggestionCollection.appendQuerySuggestion(obj.name);
});
event.detail.linguisticDetails.queryTextAlternatives.forEach(
function (element, index, array) {
if (element.substr(0, query.length).toLocaleLowerCase() === query) {
suggestionCollection.appendQuerySuggestion(element);
}
});
}));
};
if (query.length > 3) {
API.stationRequest(query, callback);
}
}
我或多或少地复制了Windows WinJS网站的示例,但是......它在$("#response")
- 元素中很好地向我显示了响应文本,但是没有框或列表。
失败是什么。