Created
December 6, 2019 06:30
-
-
Save edoves/de178b0ecb11cefcc88444d98d57a468 to your computer and use it in GitHub Desktop.
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
{ | |
"todoitem": [ | |
{ | |
"id": 1, | |
"item": "first todo", | |
"complete": true | |
}, | |
{ | |
"id": 2, | |
"item": "second todo", | |
"complete": false | |
}, | |
{ | |
"id": 3, | |
"item": "third todo", | |
"complete": false | |
} | |
] | |
} | |
$(document).ready(function() { | |
$.getJSON('http://localhost:3000/todoitem', updateFeedback); | |
function updateFeedback(data) { | |
let outPut = ''; | |
$.each( data, function( i, todo ) { | |
outPut += ` | |
<li id=${todo.id} class="list-group-item d-flex justify-content-between align-items-center "> | |
${todo.item} | |
<div class="action-btn ml-auto d-flex align-items-center"> | |
<i class="mx-2 fa fa-edit edit"></i> | |
<i class="mx-2 fa fa-trash-o delete"></i> | |
<input class="mx-2" type="checkbox"> | |
</div> | |
</li> | |
`; | |
$('.list-group').html(outPut); | |
}); | |
} | |
$('#todo-form').submit(function (e) { | |
e.preventDefault(); | |
$.post('http://localhost:3000/todoitem', { | |
item: $('#item-input-value').val(), | |
complete: false | |
}, updateFeedback); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment