Last active
December 5, 2016 17:08
-
-
Save ducin/0c8b531b226bdecaa5f72d23587fc014 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
node_modules |
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
function bookTemplate(book) { | |
return '<strong>' + book.author + '</strong>: ' + book.id; | |
} | |
function booksTemplate(books) { | |
var html = books.map(function(book){ | |
return '<li>' + bookTemplate(book) + '</li>'; | |
}).join('') | |
return '<ul>' + html + '</ul>'; | |
} | |
$(document).ready(function () { | |
// var x = 0; | |
$('#btn').on('click', function () { | |
// x += 1; | |
// console.log('siema!'); | |
// $('#container').html('olaboga' + x); | |
$.get('http://localhost:3000/books').then(function(response){ | |
// console.log(response); | |
// console.log(booksTemplate(response)); | |
$('#container').html(booksTemplate(response)); | |
}); | |
}); | |
}); |
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
<html> | |
<head> | |
<title>Buka</title> | |
<script src="node_modules/jquery/dist/jquery.js"></script> | |
<script src="node_modules/handlebars/dist/handlebars.js"></script> | |
<script src="app.js"></script> | |
</head> | |
<body> | |
<h1>Hello, my friend!</h1> | |
<button id='btn'>Click me!</button> | |
<div id='container'></div> | |
</body> | |
</html> |
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
{ | |
"name": "anxi-git", | |
"version": "1.0.0", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"dependencies": { | |
"handlebars": "^4.0.6", | |
"jquery": "^3.1.1" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment