From 117739ce1c1928e7c37c3ca73a333ac0a58af077 Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Tue, 24 Mar 2015 20:23:05 -0400 Subject: [PATCH] remove iife from docs example --- docs/getting-started.md | 35 +++++------------------------------ 1 file changed, 5 insertions(+), 30 deletions(-) diff --git a/docs/getting-started.md b/docs/getting-started.md index aaa1e8f0..ccf8b2fd 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -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. -```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 //define the view-model todo.vm = { init: function() { //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 - this.description = m.prop(''); + todo.vm.description = m.prop(''); //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()) { - this.list.push(new todo.Todo({description: description()})); - this.description(""); + todo.vm.list.push(new todo.Todo({description: description()})); + todo.vm.description(""); } }; }