HTML and CSS Reference
In-Depth Information
A call to the new TodoList.displayTask function is placed now at the very bottom of the TodoList.init
method. At the same time, you remove any call to TodoList.performInitialBinding you may have in the
TodoList.init method. Here's the new layout of the TodoList.init method:
TodoList.init = function () {
// Register handler for resize events
window.onresize = addEventListener('resize', TodoList.onResize, false);
// Register handler for buttons
document.getElementById("buttonAddTask").addEventListener("click", TodoList.
addTaskClick);
document.getElementById("buttonShare").addEventListener("click", TodoList.
shareClick);
// Initialization of Share source contract
var view = Windows.ApplicationModel.DataTransfer.DataTransferManager.
getForCurrentView();
view.addEventListener("datarequested", function (e) {
var currentTask = TodoList.getTaskFromUI();
if (currentTask.description.length === 0) {
e.request.failWithDisplayText("Indicate a description of the task.");
return;
}
TodoList.shareDataAsHtml(e, currentTask);
TodoList.shareDataAsPlainText(e, currentTask);
});
// Load settings and initialize the view
TodoList.settings.load();
TodoList.displayTask(new Task());
}
With these changes, every time the application starts up the default value of the priority parameter
is read from application settings and used to initialize the user interface.
Note In particular, the changes you made here to performInitialBinding and the
introduction of the displayTask function will make it much easier to add new functions to
the application in the upcoming chapters.
Creating the Settings page
At this point, you're ready to turn your attention to the settings.html page. You give the page the
same layout as other pages. You add the following markup to the BODY element.
Search WWH ::




Custom Search