Namespace

Fake news (multipage, library)

The story so far

You have a BS template with some JS to load a navbar, and footer. You know how to make input fields, and buttons. You know how to tie JS code to events. You know how to validate. You know how to use variables to coordinate what happens across events. You know how to persist data, and erase persisted data when needed.

This lesson adds a few new things:

  • An app with multiple pages.
  • Generating HTML with JavaScript.
  • Adding a library of utility functions copied from the web

Requirements

Goals

Our app will make a fake news feed.

Dog pack

The story so far

Persisting record sets

There's a problem with the course data app in the previous lesson. It doesn't remember anything. We created a record set when the page loads:

(function($) {
    //Initialize course catalog.
    var catalog = [
        {
            id: 42,
            title: "Web apps for happy dogs",
            maxEnrollment: 40,
            location: "Monty Hall 301"
        },
        ...
    ];

It was lost when the page ended.

We want something like this:

bc.

The template

Remember that you can download a zip file, to get our standard template.

Here's the JS from the template:

cyco format-code 1