For a json data as below is there any possible way to construct a treeview consisting of underscore.js templates. I don’t have lightest knowledge on how to mix functions, recursions into underscore.js templating functionality. I don’t have the power to produce json hierarchy from the server( it is decided by upper management).
[{
name: "Home",
url: "index.html",
id: 1,
parentid: 0
}, {
name: "Company",
url: "company.html",
id: 2,
parentid: 0
}, {
name: "AboutsUs",
url: "aboutus.html",
id: 3,
parentid: 2
}]
Expected View output
<ul>
<li>
<a href="index.html">Home</a>
</li>
<li>
<a href="company.html">Company</a>
<ul>
<li>
<a href="aboutus.html">AboutUs</a>
</li>
</ul>
</li>
</ul>
yes you can,
you can use
to write javascript code.
more here http://documentcloud.github.com/underscore/#template
hope it helps,
Good Luck!