Week Ten (MGDP2050)

From Wiki @ Karl Jones dot com
Revision as of 09:38, 12 April 2016 by Karl Jones (Talk | contribs) (Save local copies of Underscore.js and Backbone.js)

Jump to: navigation, search

Week Ten of Web Design and Development II (MGDP2050).

See also Week Nine (MGDP2050) - Week Eleven (MGDP2050).

Project

Your semester project website can use whatever technologies you need to meet your own goals.

The project does not need to include everything from the weekly exercises.

  • The weekly exercises are designed to introduce students to a wide range of topics, only some of which will be relevant to your project.

For example, you probably don't want to use Backbone.js for your project:

  • A website that uses Backbone.js is built entirely around Backbone (thus the name).
  • Learning Backbone.js would take too much time -- an entire semester.

Similarly, don't use jQuery unless you really need jQuery.

The only technology (beyond HTML and CSS) to which we are committed is Bootstrap, because it is widely used for responsive web design.

Lecture notes

See Week Ten lecture notes (MGDP2050).

Exercises: in class

Goal

Create a web page which demonstrates Backbone.js and Ajax, similar to this example page.

Create week10 folder and web pages

Create a new folder named week10, and a new web page named index.html, with the usual exercise styles, title, etc.

Add content for Backbone.js

Add web page content for Backbone.js to your exercise page.

You can use View Source and copy the code from the example page, or copy the code below:

<script type="text/template" id="itemlist_template">
 <li><%= item_name %></li>
</script>

<ol id="items">
</ol>

Two things to note about the above code example:

  • The script element is playing a special role, as an Underscore template.
  • The ol element is where the Backbone will render (display) content.

In both cases, the id attribute is essential.

Save local copies of Underscore.js and Backbone.js

Save local copies of the Underscore.js and Backbone.js files in your 'scripts folder.

Upload them to your class web server -- you will need them online, later in the exercise.

Easy way

Browse the Content Delivery Network, and save the files to your scripts folder:

More technical way

Browse the web sites, and download from there, etc.:

Add script elements for Underscore.js and Backbone.js

You can use View Source and copy the code from the example page, or copy the code below:

Create a custom JavaScript file

You can use View Source and copy the code from the example page, or copy the code below:

Add script element for custom JavaScript file

Add a script element for your custom JavaScript.

You can use View Source and copy the code from the example page, or copy the code below:

Create a JSON file, and change the data

Create a JSON file named data.json, similar to this example:

Save the JSON file in your week10 folder.

Change the item names ("Solid Gold Submarine", etc.) to names of your choice, related to your project topic.

Upload work to server, and test

Note that you must test this exercise online -- it will not work locally.

Make link from Home page to exercise page

Make link from Home page to exercise page.

Upload your Home page, and test the link to your exercise.

Update your home page

On your Home page, make a link to this exercise.