remove iife from docs example

This commit is contained in:
Leo Horie 2015-03-24 20:23:05 -04:00
parent f0ca20a671
commit 117739ce1c

View file

@ -128,46 +128,21 @@ View-models are also responsible for handling business logic that revolves aroun
In the case of our todo application, the view-model needs a few things: it needs to track a running list of todos and a field for adding new todos, and it needs to handle the logic of adding to the todo and the implications of this action of the UI. In the case of our todo application, the view-model needs a few things: it needs to track a running list of todos and a field for adding new todos, and it needs to handle the logic of adding to the todo and the implications of this action of the UI.
```javascript
//define the view-model
todo.vm = (function() {
var vm = {}
vm.init = function() {
//a running list of todos
vm.list = new todo.TodoList();
//a slot to store the name of a new todo before it is created
vm.description = m.prop("");
//adds a todo to the list, and clears the description field for user convenience
vm.add = function(description) {
if (description()) {
vm.list.push(new todo.Todo({description: description()}));
vm.description("");
}
};
}
return vm
}())
```
or
```javascript ```javascript
//define the view-model //define the view-model
todo.vm = { todo.vm = {
init: function() { init: function() {
//a running list of todos //a running list of todos
this.list = new todo.TodoList(); todo.vm.list = new todo.TodoList();
//a slot to store the name of a new todo before it is created //a slot to store the name of a new todo before it is created
this.description = m.prop(''); todo.vm.description = m.prop('');
//adds a todo to the list, and clears the description field for user convenience //adds a todo to the list, and clears the description field for user convenience
this.add = function(description) { todo.vm.add = function(description) {
if (description()) { if (description()) {
this.list.push(new todo.Todo({description: description()})); todo.vm.list.push(new todo.Todo({description: description()}));
this.description(""); todo.vm.description("");
} }
}; };
} }