我有以下我无法弄清楚的问题。我有一个带有列表视图的 pageControl。该列表有一个项目模板设置,我正在从 js 脚本绑定列表。当我单击该项目以导航到另一个 pageControl 时,我添加了一个事件处理程序。事件启动,但是当我执行 WinJS.Navigation.Navigate 时,第二页没有加载。
第 1 页 html:
<div class="mediumListIconTextTemplate" data-win-control="WinJS.Binding.Template">
<div style="width: 100%; height: 100%;">
<!-- Displays the "title" field. -->
<h4 data-win-bind="innerText: name"></h4>
<!-- Displays the "picture" field. -->
<img src="#" style="width: 100%; height: 100%;" data-win-bind="alt: name; src: imageDefault" />
</div>
</div>
<div class="collection fragment">
<header aria-label="Header content" role="banner">
<button class="win-backbutton" aria-label="Back" disabled type="button"></button>
<h1 class="titlearea win-type-ellipsis">
<span class="pagetitle">Welcome to collection </span>
</h1>
</header>
<section aria-label="Main content" role="main">
<div id="basicListView"
data-win-control="WinJS.UI.ListView"
data-win-options="{itemDataSource : Data.items.dataSource,
itemTemplate: select('.mediumListIconTextTemplate'),
layout: {type: WinJS.UI.GridLayout, maxRows:1}}">
</div>
</section>
</div>
第 1 页 JS:
WinJS.UI.Pages.define("/pages/guitarCollection/guitarCollection.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 list = document.getElementById("basicListView");
list.itemDataSource = Data.items.dataSource;
list.addEventListener("iteminvoked", this._itemInvoked);
WinJS.UI.processAll();
},
unload: function () {
// TODO: Respond to navigations away from this page.
},
updateLayout: function (element, viewState, lastViewState) {
/// <param name="element" domElement="true" />
// TODO: Respond to changes in viewState.
},
_itemInvoked: function (args) {
var name = Data.items.getAt(args.detail.itemIndex).name;
WinJS.Navigation.navigate("/pages/page2/page2.html", { name: name});
}
});