From 82ceecd29030a72f7a30448d88e5c402e6282de0 Mon Sep 17 00:00:00 2001 From: Leo Horie Date: Fri, 24 Apr 2015 08:13:21 -0400 Subject: [PATCH] fix broken example in docs --- docs/mithril.request.md | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/docs/mithril.request.md b/docs/mithril.request.md index 81291ea2..d07ef0f0 100644 --- a/docs/mithril.request.md +++ b/docs/mithril.request.md @@ -479,28 +479,26 @@ where: Determines whether the `m.request` can affect template rendering. Defaults to false. - If this option is set to true, then the request does NOT call [`m.startComputation` / `m.endComputation`](mithril.computation.md), and therefore the completion of the request does not trigger an update of the view, even if data has been changed. This option is useful for running operations in the background (i.e. without user intervention). + If this option is set to true, then the request does NOT call [`m.startComputation` / `m.endComputation`](mithril.computation.md) internally, and therefore the completion of the request does not trigger an update of the view, even if data has been changed. This option is useful for running operations in the background (i.e. without user intervention). In order to force a redraw after a background request, use [`m.redraw`](mithril.redraw.md), or `m.startComputation` / `m.endComputation`. ```javascript var demo = {} - + demo.controller = function() { - return { - users: m.request({method: "GET", url: "/api/user", background: true, initialValue: []}).then(function(value) { - //force redraw - m.redraw() - return value - }) - } + var users = m.request({method: "GET", url: "test.json", background: true, initialValue: []}) + users.then(m.redraw) + return {users: users} } - + demo.view = function(ctrl) { //this view renders twice (once immediately, and once after the request above completes) - return ctrl.users.map(function(user) { - return m("div", user.name) - }) + return m("div", [ + ctrl.users().map(function(user) { + return m("div", user.name) + }) + ]) } ```