From 7b7d9b7e2009190c9b65318a1541a17bd9159c34 Mon Sep 17 00:00:00 2001 From: Shaunna Date: Tue, 28 Nov 2017 15:13:02 -0800 Subject: [PATCH 01/44] got trip list from api --- dist/index.html | 42 +++++++++++++++++++++++++++++--- src/app.js | 29 ++++++++++++++++++++-- src/app/collections/trip_list.js | 12 +++++++++ src/app/models/trip.js | 7 ++++++ 4 files changed, 85 insertions(+), 5 deletions(-) create mode 100644 src/app/collections/trip_list.js create mode 100644 src/app/models/trip.js diff --git a/dist/index.html b/dist/index.html index b873b1e..ea9bd1d 100644 --- a/dist/index.html +++ b/dist/index.html @@ -2,19 +2,55 @@ - My JavaScript App + Aventura
- +

Camino de Aventura

-
+
+
+ + + + + + + + + + + +
NameCategoryContinentWeeksCost
+
+
+
+ diff --git a/src/app.js b/src/app.js index e7af594..78fbe9d 100644 --- a/src/app.js +++ b/src/app.js @@ -6,8 +6,33 @@ import _ from 'underscore'; import './css/foundation.css'; import './css/style.css'; -console.log('it loaded!'); +//MODELS AND COLLECTIONS +import Trip from './app/models/trip'; +import TripList from './app/collections/trip_list'; + +let tripTemplate; + +const tripList = new TripList(); + +const render = function render(tripList) { + console.log(tripList); + const $trips = $('#trips') + $trips.empty(); + tripList.forEach((trip) => { + $trips.append(tripTemplate(trip.attributes)); + console.log(trip.attributes); + // console.log('trip loaded!'); + // console.log(trip); + }); +} + $(document).ready( () => { - $('main').html('

Hello World!

'); + tripTemplate = _.template($('#trip-template').html()); + + + tripList.on('update', render, tripList); + + tripList.fetch(); + }); diff --git a/src/app/collections/trip_list.js b/src/app/collections/trip_list.js new file mode 100644 index 0000000..52336ac --- /dev/null +++ b/src/app/collections/trip_list.js @@ -0,0 +1,12 @@ +import Backbone from 'backbone'; +import Trip from '../models/trip'; + +const TripList = Backbone.Collection.extend({ + model: Trip, + url: 'https://ada-backtrek-api.herokuapp.com/trips', + parse(response) { + return response + }, +}); + +export default TripList; diff --git a/src/app/models/trip.js b/src/app/models/trip.js new file mode 100644 index 0000000..349d9ca --- /dev/null +++ b/src/app/models/trip.js @@ -0,0 +1,7 @@ +import Backbone from 'backbone'; + +const Trip = Backbone.Model.extend({ + +}); + +export default Trip From 3204ab53b5cc24ebaf537b20490ab313996955a3 Mon Sep 17 00:00:00 2001 From: Shaunna Date: Tue, 28 Nov 2017 15:35:23 -0800 Subject: [PATCH 02/44] trips showing in table --- dist/index.html | 22 ++++++---------------- src/app.js | 6 +++--- 2 files changed, 9 insertions(+), 19 deletions(-) diff --git a/dist/index.html b/dist/index.html index ea9bd1d..604ae59 100644 --- a/dist/index.html +++ b/dist/index.html @@ -10,7 +10,7 @@

Camino de Aventura

-
+
@@ -33,21 +33,11 @@

Camino de Aventura

diff --git a/src/app.js b/src/app.js index 78fbe9d..cf926b3 100644 --- a/src/app.js +++ b/src/app.js @@ -16,12 +16,12 @@ const tripList = new TripList(); const render = function render(tripList) { console.log(tripList); - const $trips = $('#trips') + const $trips = $('#trips-list') $trips.empty(); tripList.forEach((trip) => { $trips.append(tripTemplate(trip.attributes)); - console.log(trip.attributes); - // console.log('trip loaded!'); + // console.log(trip.attributes); + // // console.log('trip loaded!'); // console.log(trip); }); } From aa3cb63875656fc5d6d8715cbf5f022b587ed221 Mon Sep 17 00:00:00 2001 From: Shaunna Date: Tue, 28 Nov 2017 16:26:12 -0800 Subject: [PATCH 03/44] html changes --- dist/index.html | 12 ++++++++++-- src/app.js | 4 +++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/dist/index.html b/dist/index.html index 604ae59..5e87fe4 100644 --- a/dist/index.html +++ b/dist/index.html @@ -20,12 +20,13 @@

Camino de Aventura

-
Name Cost
+
+