Sunday 15 August 2010

backbone.js - Bootstrapping data to a page rendered with handlebars -


I'm experiencing problems with bootstrapping data on initial page load.

A quick summary: I have Found a Enterprise Server with MongoDB with Express Express. All these parts work well, fix the server index page, which runs with a lot of backbone scripts. The index page runs fine, and is able to get data from server via backbone API. All this works well.

I am trying to set it up, such a server has instant calls to mongodibi and quick calls to bootstraps on fifty models or model instances. Here's the path to index page call:

  var ProfessorModel = expected ('../ data / model / professor'); Module.exports = function (app) {app.get ('/', function (request, response) {professorModel.find () .border (50) .exec (function (error, docs) {// also tried: Find () .lan () .exec (function ....) // Also tried: docs = JSON.stringify (docs) ... (at the other end with a JSON.parse ()) // Also tried: Docs.forEach (function (e, i, a) {newDocs.push (ETOsson ())} ... ... response .Redder ('index', {bootstrap: docs}};}) ;};   

On the index page, this is just & lt; script & gt; var bootstrap = {{{bootstrap}}}; & lt; / script & gt; ;

this is every The bar loads the data, but it's the browser that has a hard time parsing. I get ' parse error alarms ', unexpected token , etc. Repeat: It should be a formatting object.

In Express Docks, it notes that the response.send () is shrewd about what it sends, and in the form of a JSS Automatically here is the problem that feedback.reader () is not doing this? I think that should be a simple Y solution here

thanks

Sam

, This was a problem on the client side

Previously, my code was: var bootstrap = {{{bootstrap}}} .

Here is not being obtained as a bootstrap extreme: a string: it is being obtained as an object to solve this issue by inserting variables between single quotes:

  var bootstrap = '{{{bootstrap}}}';   

There is still a mysterious limit on the length of the string: the last 150 or so objects, JSON parsing is fail-on-load. Otherwise: Great works.

No comments:

Post a Comment