Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Note: if you plan on adding new pages you should follow the current best practices described here: How to add a pattern to the edX Pattern Library

RequireJS

Newer code uses RequireJS to manage the loading of JavaScript dependencies. You may see code like the following:

Code Block
languagejs
    require(['js/models/course'], function(Course) {
        ...
    });

This indicates that the code depends upon a class called Course which is defined in the file js/models/course.js

See RequireJS at edX for more details.

Underscore Templates

One tip that is useful for our legacy code is knowing that ``-tpl`` is often appended to the name of an Underscore.js template name inside the JavaScript code. Underscore templates are often rendered into the page with an element id ending with -tplFor example, you might see the following line of JavaScript.

...

This indicates that you'll find the Underscore file in templates/components/card/card.underscore.