我已經與代碼試圖讓JSON與winJS列表視圖綁定搞亂。例如:不能使用'in'運算符在[{「$ id」:「1」,「Distance」:0.083516275210499508,「Jo ....」)中搜索'0'。 ........WinJS需要幫助的結合JSON響應的ListView
需要一些幫助,感謝
WinJS.xhr({
url: "http://api.secondyearvisajob.com.au/api/jobs/GetNearActiveJobs",
type: "POST",
responseType: "",
data: JSON.stringify({ LocationId: 23555, kms: 10 }),
headers: { "content-type": "application/json" }
}).done(
function completed(request) {
alert(request) //[object: Object]
alert(JSON.stringify(request.response)) // my data
alert(JSON.parse(request.response)) //[object: Object],[object: Object]
alert(request.statusText)
WinJS.Namespace.define("Sample.ListView", { data: new WinJS.Binding.List(request.response) });
},
function error(request) {
alert(request)
}
);
WinJS.UI.processAll()
<div class="smallListIconTextTemplate" data-win-control="WinJS.Binding.Template" style="display: none">
<div class="smallListIconTextItem">
<div class="smallListIconTextItem-Detail">
<h4 data-win-bind="textContent: Distance"></h4>
</div>
</div>
</div>
<div id="listView"
class="win-selectionstylefilled"
data-win-control="WinJS.UI.ListView"
data-win-options="{
itemDataSource: itemDataSource :Sample.ListView.data.dataSource,
itemTemplate: select('.smallListIconTextTemplate'),
selectionMode: 'none',
tapBehavior: 'none',
layout: { type: WinJS.UI.ListLayout }
}">
</div>
謝謝,我已經解決了您在上面提到了這兩個問題,但第二個問題我解決了使用頁面上的承諾。「args.detail.setPromise(WinJS.Promise.then(NULL,」 https://msdn.microsoft。 COM/EN-US /庫/窗/應用/ dn301954.aspx – user971374 2015-04-03 01:29:43