我有一个使用 jQuery 树视图插件创建树视图的 JSP 页面。现在我想让单个文件可选择,这意味着我想在单击文件时打开一个 url。我尝试了几个示例,但没有一个有效。这是一个示例 html 页面:
<ul id="browser" class="filetree">
<li><span class="folder">Folder 1</span>
<ul>
<li><span class="file">Item 1.1</span></li>
</ul>
</li>
<li><span class="folder">Folder 2</span>
<ul>
<li><span class="folder">Subfolder 2.1</span>
<ul id="folder21">
<li><span class="file">File 2.1.1</span></li>
<li><span class="file">File 2.1.2</span></li>
</ul>
</li>
<li><span class="file">File 2.2</span></li>
</ul>
</li>
<li class="closed"><span class="folder">Folder 3 (closed at start)</span>
<ul>
<li><span class="file">File 3.1</span></li>
</ul>
</li>
<li><span class="file">File 4</span></li>
</ul>
JavaScript:
<script type="text/javascript">
$(document).ready(function(){
$("#browser").treeview({
toggle: function() {
console.log("%s was toggled.", $(this).find(">span").text());
alert("do something");
}
});
// fourth example
$("#black, #gray").treeview({
control: "#treecontrol",
persist: "cookie",
//cookieId: "treeview-black"
});
});
</script>
我该如何实施?