Lab Session: Saving data to localStorage: Difference between revisions

From NSB App Studio
Jump to navigation Jump to search
No edit summary
No edit summary
Line 3: Line 3:
== Student Outline ==
== Student Outline ==


# Open LabLocalStorage.nsx.
# Modify ''Sub Main'' to check ''localStorage'' for an element called ''weatherSaves''.  If it does not exist, initialize it to an empty array.  Remove the ''lstSaves'' initialization code.
# Modify ''Sub Main'' to check ''localStorage'' for an element called ''weatherSaves''.  If it does not exist, initialize it to an empty array.  Remove the ''lstSaves'' initialization code.
# Modify the click code for ''btnSave'' so that it adds a new entry to the ''weatherSaves'' array of ''localStorage''.  The entry should be an object containing all the weather data including the current date.
# Modify the click code for ''btnSave'' so that it adds a new entry to the ''weatherSaves'' array of ''localStorage''.  The entry should be an object containing all the weather data including the current date.
# Add a onshow event for ''frmSaves'' that initializes ''lstSaves'' with the entries from the ''weatherSaves'' array.
# Add a onshow event for ''frmSaves'' that initializes ''lstSaves'' with the entries from the ''weatherSaves'' array.
# Add a click event to ''lstSaves'' that retrieves the proper entry from ''weatherSaves'' when clicked, sets the proper values in ''frmSavedData'' and displays it.
# Add a click event to ''lstSaves'' that retrieves the proper entry from ''weatherSaves'' when clicked, sets the proper values in ''frmSavedData'' and displays it.

Revision as of 07:03, 13 December 2013

In this lab you will modify your app so you can save historical weather data in localStorage.

Student Outline

  1. Open LabLocalStorage.nsx.
  2. Modify Sub Main to check localStorage for an element called weatherSaves. If it does not exist, initialize it to an empty array. Remove the lstSaves initialization code.
  3. Modify the click code for btnSave so that it adds a new entry to the weatherSaves array of localStorage. The entry should be an object containing all the weather data including the current date.
  4. Add a onshow event for frmSaves that initializes lstSaves with the entries from the weatherSaves array.
  5. Add a click event to lstSaves that retrieves the proper entry from weatherSaves when clicked, sets the proper values in frmSavedData and displays it.