Anyone can help me to make the jstree plugin work with a template? If I remove the lines, from 38 to 44, the tmpl works and the results appear in my page, but, if I use the jstree plugin, the "treeList" will be empty.
There is no error of jscript, the results just does not appear.
- <script type="text/javascript">
- var treeData = [
- {
- name: "Samples 1",
- type: "F",
- expanded: false,
- children: [
- { name: "Sub-Samples 1", type: "F",
- children: [
- { name: "lvl2-Samples 0", type: "F" },
- { name: "lvl2-Samples 1", type: "F" }
- ]
- },
- { name: "Sub-Samples 2", type: "F" },
- { name: "Sub-Samples 3", type: "F" }
- ]
- },
- {
- name: "Samples 2",
- type: "F",
- expanded: false,
- children: [
- { name: "Sub-Samples 4", type: "F" },
- { name: "Sub-Samples 5", type: "F" }
- ]
- }
- ];
- var xtmpl;
- $(document).ready(function () {
- if (xtmpl == null)
- xtmpl = $('#treeTmpl').template("xTmpl");
- $.tmpl(xtmpl, treeData).appendTo("#treeList");
- $("#treeList").find("li").jstree({
- "ui": {
- "select_limit": 2,
- "select_multiple_modifier": "alt",
- "selected_parent_close": "select_parent"
- }
- });
- });
- </script>
- <script id="treeTmpl" type="text/x-jquery-tmpl">
- <li><span>${name}</span>
- {{if children }}
- <ul>{{tmpl(children) "#treeTmpl"}}
- </ul>
- {{/if}}
- </li>
- </script>
- <ul class="simpleTree" id="treeList">
- </ul>