forked from gertie-sheshe/techinpink
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#118543823] Styles dashboard, modifies models and controllers
- Loading branch information
andela-gnyenyeshi
committed
Apr 28, 2016
1 parent
08ea290
commit 7d7f3da
Showing
5 changed files
with
77 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,71 @@ | ||
$(function () { | ||
// GET function | ||
$('#get-button').on('click', function() { | ||
$(document).on('click', '#get-button', function() { | ||
$.ajax({ | ||
url: '/api/view', | ||
contentType: 'application/json', | ||
success: function(response) { | ||
console.log('Tulifika', response); | ||
var data = response.members; | ||
// Clear the tbody | ||
$('tbody').html(''); | ||
// Loop and append | ||
data.forEach(function print(member) { | ||
$('tbody').append( | ||
'<tr>' + | ||
"<td class='name'>' + member.name +'</td>" + | ||
'<td>Andela</td>' + | ||
'<td>Saturday</td>' + | ||
"<td><i class='material-icons delete'>delete</i></td>" + | ||
'</tr>' | ||
); | ||
}); | ||
} | ||
}); | ||
}); | ||
|
||
// POST function | ||
$('#post-button').on('click', function() { | ||
$.ajax({ | ||
url: '/api/save', | ||
method: 'POST', | ||
contentType: 'application/json', | ||
data: JSON.stringify({name: 'Gertrude Nyenyeshi'}), | ||
success: function(response) { | ||
console.log('Watuuuu', response); | ||
} | ||
}); | ||
$(document).on('click', '#post-button', function() { | ||
// Get the value from form | ||
var attendee = $('#attendee').val(); | ||
// If user has not filled form | ||
if (!attendee) { | ||
Materialize.toast('Please fill with a name :)', 4000); | ||
} else { | ||
// Post value if user has filled name | ||
$.ajax({ | ||
url: '/api/save', | ||
method: 'POST', | ||
contentType: 'application/json', | ||
data: JSON.stringify({name: attendee}), | ||
success: function(response) { | ||
$('#get-button').trigger('click'); | ||
Materialize.toast('Successfully added new user', 4000); | ||
} | ||
}); | ||
} | ||
}); | ||
|
||
// DELETE Button | ||
$(document).on('click', '.delete', function() { | ||
var del = $(this).closest('tr'); | ||
var id = del.find('.name').text(); | ||
console.log(del); | ||
console.log(id); | ||
}); | ||
|
||
// GET STARTED button function | ||
$('#get-started').on('click', function() { | ||
document.getElementById('o').innerHTML = "<h4 id='register'>Enter Attendee: </h4> " + | ||
"<form class='col s12'> <div class='row'> <div class='input-field col s6'> " + | ||
" <input type='text' id='attendee'> <label for='attendee'> Attendee" + | ||
"</label> </div> </div> </form> <hr>"; | ||
var b; | ||
"</label> <a id='post-button' class='waves-effect waves-light btn #880e4f pink darken-4'>Add</a>" + | ||
"</div> </div> </form> <a id='get-button' class='waves-effect waves-light btn #880e4f pink darken-4 col s2 offset-s8'>View all</a><hr>" + | ||
"<div class='row'><table class='striped col s10 offset-s1' id='list'> " + | ||
"<thead><tr><th>Name</th><th>Venue</th><th>Day</th>" + | ||
"</tr></thead><tbody><tr><td class='name'>Gertrude</td><td>Andela</td><td>Saturday</td><td>" + | ||
"<i class='material-icons delete'>delete</i></td></tr></tbody></table></div>"; | ||
|
||
$('#get-started').text(''); | ||
// this.id = "go-back"; | ||
}); | ||
|
||
// $(document).on('click', '#go-back', function() { | ||
// document.getElementById("o").innerHTML = "<h2>OoFJHFDF</h2>"; | ||
// console.log('Ola'); | ||
// }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,10 @@ | |
name: { | ||
type: String, | ||
required: true | ||
}, | ||
email: { | ||
type: String, | ||
required: true | ||
} | ||
}); | ||
|
||
|