-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Closed #65: using ids again, version bump!
- Loading branch information
Jackson Gariety
committed
Feb 16, 2014
1 parent
161b9f1
commit 4047ffd
Showing
6 changed files
with
37 additions
and
33 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,7 +1,8 @@ | ||
var TodoList = require('../app') | ||
, $ = require('jquery') | ||
|
||
var AboutView = module.exports = new TodoList.View('Todo', { | ||
render: function (document) { | ||
document.querySelector('main').innerHTML = 'About my app.' | ||
$(document).find('main').html('About my app.') | ||
} | ||
}) |
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,30 +1,25 @@ | ||
var TodoList = require('../app') | ||
, Mustache = require('mustache') | ||
, TodoController = require('../controllers/todo') | ||
, _ = require('../../../lib/sara').Utils | ||
, Todo = require('../models/todo') | ||
, $ = require('jquery') | ||
|
||
var TodoView = module.exports = new TodoList.View('Todo', { | ||
template: TodoList.template('todo', '../templates/todo.html') | ||
, render: function (document) { | ||
Todo.all().on('add remove changeAny', render.bind(this)) | ||
render.bind(this)() | ||
|
||
function render() { | ||
Todo.all().forEach(function (todo) { | ||
todo.key = todo.id() | ||
}) | ||
$(document).find('main').html(Mustache.render(this.template.toString(), { todos: Todo.all(), completed: Todo.completed() })) | ||
|
||
// render | ||
document.querySelector('main').innerHTML = Mustache.render(this.template.toString(), { todos: Todo.all(), completed: Todo.completed() }) | ||
with (TodoController) { | ||
$(document).find('div button').click(clear) | ||
$(document).find('form').submit(create) | ||
$(document).find('input[type="checkbox"]').click(toggleChecked) | ||
} | ||
|
||
return render.bind(this) | ||
} | ||
|
||
// events | ||
document.querySelector('div button').onclick = TodoController.clear | ||
document.querySelector('form').onsubmit = TodoController.create | ||
|
||
_(document.querySelectorAll('input[type="checkbox"]')).forEach(function (input) { | ||
input.onclick = TodoController.toggleChecked | ||
}) | ||
} | ||
Todo.all().on('add remove changeAny', render.call(this)) | ||
} | ||
}) |
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