| Page 1 of 1 | [ 3 posts ] |
John DaCosta
|
I cannot seem to get my template to render my Jobs Collection, however I can get it to render a JSON String that I pass into the template function directly.
Can anyone help me identify what i am doing wrong or if there is a bug? The template is here: Code: <script id="job-template" type="text/x-handlebars-template"> <div id="job-template-header">Job List</div> <ul> {{#items}} <li>{{name}}</li> {{/items}} </ul> </script> The javascript is at the jump below: http://pastie.org/3642147 The code which renders is: Code: var html = template({items:[{name:'Job 100'},{name:'Job 200'}]}); The code that does not work is: Code: var html = template(jsonstring ); |
|
AFAIK, a template doesn't accept a string of JSON, it's expecting an object.
|
John DaCosta
|
davglass wrote: AFAIK, a template doesn't accept a string of JSON, it's expecting an object. Thanks, I got it to work. When I pass the object "jobs" the template function failed. When I stringified the object, the template function failed. In the end the successful method was to 1. serialize object to json, then 2. to convert the json into an object: Code: html = template({'jobs':Y.JSON.parse(Y.JSON.stringify(jobs,null,4))}); |
| Page 1 of 1 | [ 3 posts ] |
| You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum |
© 2006-2013 Yahoo! Inc. All rights reserved.
All code on this site is licensed under the BSD License unless stated otherwise.
About This Site · Security Contact Info
Powered by phpBB® Forum Software © phpBB Group