And*_*y B 13 jquery jquery-plugins jstree
我是Jquery和JS Tree的新手,但学会喜欢它.我使用php生成的xml设置了一个树形菜单(参见下面的代码).它按预期工作,但有一个例外 - 链接未激活.
我知道有一些我不明白的基本知识.短期我只想让链接作为普通链接运行.长期我希望他们触发ajax调用,重新加载页面上的特定div.
谁能指出我正确的方向?非常感谢你的帮助!
$(function () {
$("#mainMenu").jstree({
xml_data : { data : <?php $menu->deliver(); ?> },
core : { animation : 1000 }
ui : { select_limit : 1, selected_parent_close : false },
themes : { theme : "default", dots : true, icons : false },
types : { types : { "heading" : { select_node : true } } },
plugins : [ "themes", "xml_data", "ui", "types" ]
});
});
Run Code Online (Sandbox Code Playgroud)
示例xml(单项):
"<root><item id='pubPages_home' parent_id='0'><content><name href='?
a=pubPages&f=home'>Public Home</name></content></item><root>"
Run Code Online (Sandbox Code Playgroud)
roa*_*ach 15
.bind("select_node.jstree", function (e, data) {
var href = data.node.a_attr.href
document.location.href = href;
}) ;
Run Code Online (Sandbox Code Playgroud)
jstree版本:"3.0.0",jquery:last
更新: 或对我来说最好的方式:
.bind("select_node.jstree", function (e, data) {
$('#jstree').jstree('save_state');
}) ;
.on("activate_node.jstree", function(e,data){
window.location.href = data.node.a_attr.href;
})
Run Code Online (Sandbox Code Playgroud)
小智 2
我认为您需要显式编写树节点链接的单击处理程序。JsTree 自行获取点击事件,不让它去重定向页面。
我会尝试这样做:
$('#mainMenu').bind('select_node.jstree', function(e,data) {
window.location.href = data.rslt.obj.attr("href");
});
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12998 次 |
| 最近记录: |