HTML and CSS Reference
In-Depth Information
This method takes a few of the lines you already had in
TodoList.populateTaskList
. In particular, it
takes out the configuration work (such as, template and event binding) that only needs be done once.
You call
TodoList.setupTaskList
from within
TodoList.init
just before calling
TodoList.populateTaskList
.
TodoList.setupTaskList();
TodoList.populateTaskList();
Of course, you remove the two lines moved to
TodoList.setupTaskList
from
TodoList.populateTaskList
.
Finally, you take care of the code that runs when the user selects a task from the list. You add the
following method to
todolist.js
:
TodoList.taskSelected = function (eventInfo) {
eventInfo.detail.itemPromise.then(function (item) {
TodoList.displayTask(item.data);
});
}
You ask (asynchronously) for the selected item and, when you get it, you extract the contained
data
—the
Task
object—and pass it to the familiar
TodoList.displayTask
method, as shown in
Figure 10-13.
FIGURE 10-13
Selecting a task for editing.
Search WWH ::
Custom Search