Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pipes - Sairagul - BackTrek #45

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Sorting added
  • Loading branch information
sairagula committed Dec 1, 2017
commit 417045eeb4f9fe6308d3bd9994333697396492cb
23 changes: 19 additions & 4 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -54,8 +54,19 @@
const tripList = new TripList();
tripList.on('update',render);

// sorting by header element
tripList.on('sort', render);
TRIP_FIELDS.forEach((field) => {
const headerData = $(`th.sort.${ field }`);
headerData.on('click', (event) => {
// console.log(`sorting table by ${ field }`);
tripList.comparator = field;
tripList.sort();
});
});

// Retrieving all trips by clicking the button
$('#load').on('click', function(){
// $('#trip-list').show();
tripList.fetch({
success: function(collection, response){
$('#trips').show();
@@ -64,9 +75,12 @@
});
});

// $('#add_trip').on('click', function(){
// $('#show_form').show();
// };
$('#add_trip').on('click', function(){
event.preventDefault();
$('#show_form').show();
};

// Adding trip to the DB
$("#add-trip-form").on('submit', function(event){
event.preventDefault(); // stops after reading user input, doesn't do anything yet
let tripData = {};
@@ -84,6 +98,7 @@
})
});

// Reserving a trip
$("#trip").on('submit', "#reservation-form", function(event){
event.preventDefault();
let reservationData = {};
1 change: 0 additions & 1 deletion src/app/collections/trip_list.js
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@ import Trip from '../models/trip';
const TripList = Backbone.Collection.extend({
model: Trip,
url: 'https://ada-backtrek-api.herokuapp.com/trips',

comparator: 'id'
});

4 changes: 2 additions & 2 deletions src/css/style.css
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@
font-family: fantasy;
font-style: italic;
}
#load{
#load, #add_trip{
text-align: center;
border: 1px black solid;
border-radius: .2em ;
@@ -22,7 +22,7 @@
margin-top: 2%;
}

#load:hover, input.button:hover{
#load:hover, #add_trip:hover, input.button:hover{
background-color: lightsteelblue;
}