add ejs and make some views
This commit is contained in:
33
index.html
33
index.html
@@ -3,45 +3,14 @@
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<script type="text/javascript" src="libs/jquery.min.js"></script>
|
||||
<!--
|
||||
It made life easier for many years, and it makes it really easy to change the dom and make ajax calls.
|
||||
So let's include it in our html file. The latest browsers make jQuery almost useless, but it's still nice to
|
||||
have it around for a lot of things for now.
|
||||
-->
|
||||
<script type="text/javascript" src="libs/ejs.js"></script>
|
||||
|
||||
<link rel="stylesheet" href="css/bootstrap.min.css">
|
||||
<!-- bootstrap -->
|
||||
|
||||
<link rel="stylesheet" href="css/app.css">
|
||||
<!--
|
||||
This file will be empty in the beginning, but since we know we will be using this let's add it now already.
|
||||
-->
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!--
|
||||
We have the first screen of our app inside the index.html file.
|
||||
This is not that nice, because if we have to add more screens later we clutter our index.html file with all
|
||||
the screens our app will have.
|
||||
So we will have to move this out later.
|
||||
-->
|
||||
|
||||
<div class="container">
|
||||
<h1>Tasks</h1>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<form id="add-task-form" class="form-inline">
|
||||
<div class="form-group">
|
||||
<label for="task" class="control-label">New task</label>
|
||||
<input type="text" class="form-control" id="task">
|
||||
</div>
|
||||
<button class="btn btn-default" id="add-task" type="submit">Add</button>
|
||||
</form>
|
||||
<!-- our tasks go here -->
|
||||
<ol id="task-list" class="list-group">
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="index.js"></script>
|
||||
|
8
index.js
8
index.js
@@ -1,7 +1,11 @@
|
||||
(function($) {
|
||||
//events
|
||||
$(document).on('submit', '#add-task-form', function(ev) {
|
||||
ev.preventDefault();
|
||||
var newTask = '<li class="list-group-item">' + $('#task').val() + '</li>';
|
||||
$('#task-list').append(newTask);
|
||||
|
||||
$('#task-list').append('views/task-item.ejs', {title: $('#task').val()});
|
||||
});
|
||||
|
||||
//initial page setup
|
||||
$('.container').html('views/tasks.ejs', {});
|
||||
})(jQuery)
|
1777
libs/ejs.js
Normal file
1777
libs/ejs.js
Normal file
File diff suppressed because it is too large
Load Diff
1
views/task-item.ejs
Normal file
1
views/task-item.ejs
Normal file
@@ -0,0 +1 @@
|
||||
<li class="list-group-item"><%= title %></li>
|
16
views/tasks.ejs
Normal file
16
views/tasks.ejs
Normal file
@@ -0,0 +1,16 @@
|
||||
<h1>Tasks</h1>
|
||||
<div class="panel panel-default">
|
||||
<div class="panel-body">
|
||||
<form id="add-task-form" class="form-inline">
|
||||
<div class="form-group">
|
||||
<label for="task" class="control-label">New task</label>
|
||||
<input type="text" class="form-control" id="task">
|
||||
</div>
|
||||
<button class="btn btn-default" id="add-task" type="submit">Add</button>
|
||||
</form>
|
||||
|
||||
<!-- our tasks go here -->
|
||||
<ol id="task-list" class="list-group">
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
Reference in New Issue
Block a user