[Pkg-javascript-commits] [backbone] 10/211: Adding FAQ section for bootstrapping

Jonas Smedegaard js at moszumanska.debian.org
Sat May 3 16:59:57 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to tag 0.5.0
in repository backbone.

commit 9f842bda94e31c06520696ead6add8441da65611
Author: Jeremy Ashkenas <jashkenas at gmail.com>
Date:   Wed Dec 8 11:28:13 2010 -0500

    Adding FAQ section for bootstrapping
---
 index.html | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/index.html b/index.html
index df6000f..dbb3d5a 100644
--- a/index.html
+++ b/index.html
@@ -269,6 +269,7 @@
     <ul class="toc_section">
       <li>– <a href="#FAQ-events">Catalog of Events</a></li>
       <li>– <a href="#FAQ-nested">Nested Models & Collections</a></li>
+      <li>– <a href="#FAQ-bootstrap">Loading Bootstrapped Models</a></li>
       <li>– <a href="#FAQ-mvc">Traditional MVC</a></li>
       <li>– <a href="#FAQ-this">Binding "this"</a></li>
       <li>- <a href="#FAQ-rias">Other RIA Frameworks</a></li>
@@ -1875,6 +1876,26 @@ var Inbox = new Mailbox;
 Inbox.messages.fetch();
 </pre>
 
+    <p id="FAQ-bootstrap">
+      <b class="header">Loading Bootstrapped Models</b>
+      <br />
+      When your app first loads, it's common to have a set of initial models that
+      you know you're going to need, in order to render the page. Instead of 
+      firing an extra AJAX request to <a href="#Collection-fetch">fetch</a> them,
+      a nicer pattern is to have their data already bootstrapped into the page.
+      You can then use <a href="#Collection-refresh">refresh</a> to populate your
+      collections with the initial data. At DocumentCloud, in the 
+      <a href="http://en.wikipedia.org/wiki/ERuby">ERB</a> template for the 
+      workspace, we do something along these lines:
+    </p>
+
+<pre>
+<script>
+  Accounts.refresh(<%= @accounts.to_json %>);
+  Projects.refresh(<%= @projects.to_json(:collaborators => true) %>);
+</script>
+</pre>
+
     <p id="FAQ-mvc">
       <b class="header">How does Backbone relate to "traditional" MVC?</b>
       <br />

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/backbone.git



More information about the Pkg-javascript-commits mailing list