I am new to Jquery and JS Tree but learning to love it. I have set up a tree menu using php generated xml (see code below). It works as expected with one exception - The links are not active.
I know there is something basic I don't understand. Short term I just want the links to function as normal links. Long term I want them to trigger an ajax call that will reload a specific div on the page.
Can anyone point me in the right direction? Thanks much for the help!
$(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" ]
});
});
Example xml (single item):
"<root><item id='pubPages_home' parent_id='0'><content><name href='?
a=pubPages&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 version: "3.0.0", jquery: last
update: or best way for me:
.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;
})