林學建一個窗口在Visual Studio 8.1導航軟件表現2013年
從的PageControl犯規火ready事件Winjs導航
伊夫內部創建home.html的一個按鈕,並綁定一個click事件執行導航到pageControl元素稱爲htmlcontrols(導航工作正常)。接下來,我創建了一個名爲otherpage的新pageControl,並且我添加了另一個按鈕,但是這次是在htmlcontrols中。我將另一個單擊事件綁定到此按鈕以從htmlcontrols導航到其他頁面。
導航流程應該是:
家(點擊) - > htmlcontrols(點擊) - > otherpage
第二導航不工作,我已經試圖把一個調試器就緒事件中的otherpage .js但它不會觸發。
我完全失去了!
htmlcontrols.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>htmlcontrols</title>
<link href="htmlcontrols.css" rel="stylesheet" />
<script src="htmlcontrols.js"></script>
</head>
<body>
<div class="htmlcontrols fragment">
<header class="page-header" aria-label="Header content" role="banner">
<button class="back-button" data-win-control="WinJS.UI.BackButton"></button>
<h1 class="titlearea win-type-ellipsis">
<span class="pagetitle">Welcome to htmlcontrols</span>
</h1>
</header>
<section class="page-section" aria-label="Main content" role="main">
<button id="newButton">Link to another page!</button>
</section>
</div>
</body>
</html>
htmlcontrols.js:
// For an introduction to the Page Control template, see the following documentation:
// http://go.microsoft.com/fwlink/?LinkId=232511
(function() {
"use strict";
var nav = WinJS.Navigation;
WinJS.UI.Pages.define("/pages/htmlcontrols.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) {
// NEVER REACHES THIS POINT
debugger;
newButton.addEventListener("click", function (e) {
nav.navigate("/pages/otherpage/otherpage.html");
}, false);
},
unload: function() {
// TODO: Respond to navigations away from this page.
},
updateLayout: function (element) {
/// <param name="element" domElement="true" />
// TODO: Respond to changes in layout.
}
});
})();