mirror of
https://github.com/Lomanic/presence-button-web
synced 2024-11-16 18:57:29 +00:00
27 lines
649 B
JavaScript
27 lines
649 B
JavaScript
// client-side js
|
|
// run by the browser each time your view template is loaded
|
|
|
|
// by default, you've got jQuery,
|
|
// add other scripts at the bottom of index.html
|
|
|
|
$(function() {
|
|
console.log('hello world :o');
|
|
|
|
$.get('/dreams', function(dreams) {
|
|
dreams.forEach(function(dream) {
|
|
$('<li></li>').text(dream).appendTo('ul#dreams');
|
|
});
|
|
});
|
|
|
|
$('form').submit(function(event) {
|
|
event.preventDefault();
|
|
var dream = $('input').val();
|
|
$.post('/dreams?' + $.param({dream: dream}), function() {
|
|
$('<li></li>').text(dream).appendTo('ul#dreams');
|
|
$('input').val('');
|
|
$('input').focus();
|
|
});
|
|
});
|
|
|
|
});
|