{ | |
"viz": "timeseries", | |
"requests": [ | |
{ | |
"style": { | |
"palette": "dog_classic", | |
"type": "solid", | |
"width": "thick" | |
}, | |
"type": "line", |
You just learned some of the incredible magic and utility of Backbone Collections. Now it's your turn to put them to practical use.
- Create a Backbone Model called
VillainModel
- Provide the
VillainModel
with defaults (set to null) for the following attributesid
name
You just learned the magical AJAX-y ease of working with a Backbone model. Now it's your turn to implement a backbone model that you can persist.
- Use
Backbone.Model.extend()
to create a new constructor function calledFootSoldier
.
- Note: there are a number of FootSoldier's in the database. For now, let's assume we're only interested in the
FootSoldier
with id of 1.
- Using your new constructor function, instantiate the
FootSoldier
. - Use Backbone's convenient
.fetch()
to retrieve theFootSoldier
's data via ajax.
- Create a template that generates html in the format below, but allowing for dynamic values to be inserted for the img tag's
src
attribute, as well as the text of the span tag:
<div class="match clearfix">
<img src="http://api.randomuser.me/portraits/women/2.jpg" alt=""><span>Sarana</span>
var movies = [
{ title: "Chef", imgURL: "http://cdn5.nflximg.net/webp/9665/11949665.webp" },
{ title: "House of Cards", imgURL: "http://cdn7.nflximg.net/webp/7677/11747677.webp" },
{ title: "His Girl Friday", imgURL: "http://cdn0.nflximg.net/images/0030/2210030.jpg" },
{ title: "Chinatown", imgURL: "http://cdn0.nflximg.net/images/3158/11143158.jpg" },
{ title: "What's Eating Gilbert Grape?", imgURL: "http://cdn9.nflximg.net/webp/1459/8191459.webp" },
{ title: "Robocop (1987)", imgURL: "http://cdn6.nflximg.net/webp/0456/8730456.webp" }
];
The year is 2005, and a new technique called AJAX is making waves in the global web development community. It seems this AJAX thing allows developers to use JavaScript to fire off HTTP requests that send and retrieve new information without ever reloading the page.
WeatherVain Inc. is ultra intrigued by AJAX, as they think it will allow users to consume the OpenWeatherMap API to display up-to-date weather information about a given city. You've been tasked with validating their idea.
- Head to the OpenWeatherMap API, and validate that it can be used to retrieve the current weather conditions of a given city.
- What data types does the API serve?
Answer the questions below in the order they appear:
- What DOM node do you want to add a 'scroll' event listener to?
- Answer: the
window
object
- How can you ensure your 'scroll' event listener is firing?
- Answer: add a
console.log
to the event listener's callback function
- How can you determine how far the user has scrolled?
- Answer:
$(window).scrollTop();
returns an integer
Peter Lai thinks you've done a great job on the shopping_db
database, but now he wants you to normalize our data, ie split the repetitive parts into their own tables.
- Within
shopping_db
, create a table,stores
for holding your store data. Each store should have:
- an auto-incrementing primary key of
id
- a
name
attribute - a
slogan
attribute
You just learned how to insert (create) records into a table, and how to select (read) records using structured query language. Because these skills are so fundamental, you have been tasked with adding
- build muscle memory for creating and reading records in SQL
- Insert a student into the
students
table.