O'Reilly logo

HTML5 Web Application Development By Example Beginner's guide by J.M. Gustafson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Time for action – delaying the saves

Note

See the code in Chapter 3\example3.3.

We can alleviate this problem by delaying the save to localStorage for a period of time to wait until all of the user interaction has finished. This is pretty easy to implement using JavaScript's setTimeout() function. We will make this change in the saveTaskList() method, but first we need a global variable in the TaskAtHandApp object to keep track of the timeout ID returned by setTimeout():

function TaskAtHandApp()
{
    var version = "v3.3",
        appStorage = new AppStorage("taskAtHand"),
        taskList = new TaskList(),
        timeoutId = 0;

When changes are pending a save, we want to display a message in the status element at the bottom of the page so the user knows that their changes ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required