Note that there are some explanatory texts on larger screens.

plurals
  1. POBackboneJs: how do i bootstrap my data in the page markup, and when do i assign them to my collections
    text
    copied!<p>So, building an application that uses multiple (2 for now) global collections, it is a catalog of both documents and patients, they have relations, but not as in, 1 document or a list of documents belonging to 1 patient, so they are in fact 2 separate collections,</p> <p>my app is structured in a module system very similar to how it is described here: <a href="http://weblog.bocoup.com/organizing-your-backbone-js-application-with-modules" rel="nofollow">http://weblog.bocoup.com/organizing-your-backbone-js-application-with-modules</a></p> <p>the backbone.js documentation says about bootstrapping, to do something like this,</p> <pre><code>&lt;script&gt; Accounts.reset(&lt;%= @accounts.to_json %&gt;); &lt;/script&gt; </code></pre> <p>that is within a Rails application, i would however need to do it differently in asp.net MVC3, most likely i would just print out my json string without the &lt;%= %> which isn't razor view engine style)</p> <p>but my question here is,</p> <p>this <code>Accounts.reset(...data...);</code> is just floating somewhere in my markup, it is not in any way nicely structured in my module system, isn't there a way to nicely do this? where as i can get the data, from within my module?</p> <p>and another side question, suppose i have a route in my backbone app <a href="http://example.com/#documents" rel="nofollow">http://example.com/#documents</a></p> <p>and someone calls this link directly, will my app have the data ready (from the bootstrap) on time, before the route itself is executed?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload