-
Book Overview & Buying
-
Table Of Contents
KnockoutJS by Example
By :
The fourth feature of our to-do application is to give the users the ability to set priority for tasks. We will do this by adding a dropdown with options for priority. The user will be able to select the appropriate priority when creating a task. The priority of the task will be displayed in a new column in our tasks table. The options for the priority will be 1, 2, and 3.
Let's start by adding the priority attribute to our task model. Open the ToDoList module in the todolist.js file and add the attribute to capture the priority of the task. This attribute must be an observable for two-way data binding to work. Your task model should look similar to this:
/* the task */
var task = {
name: ko.observable(),
description: ko.observable(),
priority: ko.observable()
};We also need to add this attribute to the task object we create and push to the tasks array in our addTask method. The priority attribute in the task object we create for the...
Change the font size
Change margin width
Change background colour