Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>This may not be an answer exactly, but it was too long for a comment...</p> <p>Look at this jsfiddle: <a href="http://jsfiddle.net/KvXTA/" rel="nofollow">http://jsfiddle.net/KvXTA/</a></p> <pre><code>var seeds = [{ name: 'Team 1', _id: 5134d71192cf972226000003, __v: 0, key: 1362417425623 },{ name: 'Team 2', _id: 5139dc66b48da58d0e000001, __v: 0, key: 1362746470498 },{ name: 'Team 3', _id: 5139dda45f1598440f000001, __v: 0, key: 1362746788314 },{ name: 'Team 4', _id: 513b2c66cfd50dce11000001, __v: 0, key: 1362832486554 }]; console.log(seeds); </code></pre> <p>notice how the console outputs</p> <pre><code>Uncaught SyntaxError: Unexpected token ILLEGAL </code></pre> <p>That's because of the _id fields. I'm surprised you say that the serialized version has the same problem, since it should have surrounded the ID's in quotes. If you don't need the ID's at all, you can get rid of them in the serialized version by using a replacer function.</p> <pre><code>var seedsSerialized = JSON.stringify(teams, function (key, val) { return key === '_id' ? undefined : val; ); res.render('tournamentDetails', { seedsSerialized: seedsSerialized }); </code></pre> <p>Then use that serialized version to initialize <code>seeds</code> in the template.</p> <pre><code>script var seeds = !{seedsSerialized}; </code></pre> <p>My earlier comment about order of including scripts wasn't a concern that maybe another file was creating a seeds variable, it was that you might have been including a file which used <code>seeds</code> before <code>seeds</code> was actually declared.</p> <p>For example:</p> <pre><code>&lt;script src='logSeeds.js'&gt;&lt;/script&gt; &lt;script&gt; var seeds = [ ... ]; &lt;/script&gt; </code></pre> <p>where logSeeds.js is:</p> <pre><code>console.log(seeds); </code></pre> <p>would obviously output <code>undefined</code> since <code>seeds</code> hasn't been declared yet. It was just a thought, not necessarily your situation.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

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