From bfd043aa5ef943e5a1282bd62365976f4440c413 Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Wed, 1 Oct 2014 22:17:49 -0400 Subject: [PATCH] guide updates --- docs/components.md | 2 +- docs/getting-started.md | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/docs/components.md b/docs/components.md index 5c4df252..81837caf 100644 --- a/docs/components.md +++ b/docs/components.md @@ -212,7 +212,7 @@ var autocompleter = function() { As you can see, the code is exactly the same as before, with the exception that it is wrapped in a function that returns the module. This allows us to easily create copies of the autocompleter: -``` +```javascript //here's an example of using the autocompleter var dashboard = {} dashboard.controller = function() { diff --git a/docs/getting-started.md b/docs/getting-started.md index ed2108ba..6adb290c 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -134,7 +134,9 @@ todo.vm.init = function() { } ``` -The code above defines the view-model object. It has three members: `list`, which is simply an array, `description`, which is an `m.prop` getter-setter function with an empty string as the initial value, and `add`, which is a method that adds a new Todo instance to `list` if an input description getter-setter is not an empty string. Later in this guide, we'll pass the `description` property as the parameter to this function. When we get there, I'll explain why we're passing description as an argument instead of simply using OOP-style member association. +The code above defines a view-model object called `vm`. It is simply a javascript object that has a `init` function. This function initializes the `vm` object with three members: `list`, which is simply an array, `description`, which is an `m.prop` getter-setter function with an empty string as the initial value, and `add`, which is a method that adds a new Todo instance to `list` if an input description getter-setter is not an empty string. + +Later in this guide, we'll pass the `description` property as the parameter to this function. When we get there, I'll explain why we're passing description as an argument instead of simply using OOP-style member association. You can use the view-model like this: @@ -393,7 +395,7 @@ So far, we've been using `m.render` to manually redraw after we made a change to ```javascript //render the todo module inside the document DOM node -m.module(document, todo); +m.module(document, {controller: todo.controller, view: todo.view}); ``` Mithril's auto-redrawing system keeps track of controller stability, and only redraws the view once it detects that the controller has finished running all of its code, including asynchronous AJAX payloads. Likewise, it intelligently waits for asynchronous services inside event handlers to complete before redrawing. @@ -468,7 +470,7 @@ todo.view = function() { }; //initialize the application -m.module(document, todo); +m.module(document, {controller: todo.controller, view: todo.view}); ```