gpt4 book ai didi

jquery - JS 树链接未激活

转载 作者:行者123 更新时间:2023-12-03 22:08:20 26 4
gpt4 key购买 nike

我是 Jquery 和 JS Tree 的新手,但正在学习喜欢它。我已经设定使用 php 生成的 xml 建立树形菜单(参见下面的代码)。它的工作原理是预期有一个异常(exception) - 链接未激活。

我知道有些基本的东西我不明白。短期我只是希望链接像普通链接一样发挥作用。从长远来看,我希望他们触发 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" ]
});
});

示例 xml(单个项目):

"<root><item id='pubPages_home' parent_id='0'><content><name href='?
a=pubPages&amp;f=home'>Public Home</name></content></item><root>"

最佳答案

            .bind("select_node.jstree", function (e, data) {
var href = data.node.a_attr.href
document.location.href = href;
}) ;

jstree版本:“3.0.0”,jquery:最后

更新:或者对我来说最好的方法:

.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;
})

关于jquery - JS 树链接未激活,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8378561/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com