I have spent a number of hours trying to figure this out and I'm just not getting anywhere. Adding the state plugin causes ie, chrome and firefox to reload the page over and over. Any attempt to manipulate the tree (close or open nodes) will have an effect for a split second, then the state gets reset when the page reloads. The reloading happens even if I don't manipulate the tree. Any help would be greatly appreciated.
$('#NavTreeContainer').jstree({
'core': {
'themes': {
'name': 'default',
'responsive': true,
'stripes': true,
'dots': true,
'icons': false
}
},
'state' : { 'key' : 'navTree' },
'plugins' : [ 'state' ]
}).on('select_node.jstree', function(e, data) {
document.location = data.instance.get_node(data.node, true).children('a').attr('href');
});
$('#ExpandAllNavTreeButton').click(function() {
$('#NavTreeContainer').jstree('open_all');
});
$('#CollapseAllNavTreeButton').click(function() {
$('#NavTreeContainer').jstree('close_all');
});(function ($) {
Drupal.behaviors.jstree_menu = {
attach: function (context, settings) {
var params = {};
try {
Drupal.jstree_menu.variables.theme = Drupal.jstree_menu.removeDoubleQuotes(settings.jstree_menu.theme);
Drupal.jstree_menu.variables.rem_border = Drupal.jstree_menu.removeDoubleQuotes(settings.jstree_menu.rem_border);
}
catch (err) {
// Default values if something goes wrong.
Drupal.jstree_menu.variables.theme = 'default';
Drupal.jstree_menu.variables.rem_border = 0;
}
if (Drupal.jstree_menu.variables.theme == 'proton') {
params = {
'core': {
'themes': {
'name': Drupal.jstree_menu.variables.theme,
'icons':true,
'responsive':true
}
},
'state': {
'key': 'navigation'
},
'search': {
'fuzzy': true
},
'plugins': [
'search', 'state'//, 'checkbox'
]
};
}
$('[id^=menu-jstree-]').jstree(params);
document.getElementById("btn").onclick = function()
{
var str = document.getElementById("search_ay").value;
$('[id^=menu-jstree-]').jstree(true).search(str);
};
document.getElementById("search_ay").onkeyup = function()
{
var str = this.value;
$('[id^=menu-jstree-]').jstree(true).search(str);
};
if (Drupal.jstree_menu.variables.rem_border == 1) {
$('[id^=menu-jstree-]').addClass('rem-border');
}
}
};
})(jQuery);jQuery(document).ready(function() {
// When a link is clicked, we redirect to href.
jQuery('[id^=menu-jstree-]').on("select_node.jstree", function (e, data) {
document.location = data.instance.get_node(data.node, true).children('a').attr('href');
/*var href = data.node.a_attr.href;
document.location.href = href;*/
});
});$('#jstree').jstree({
core : {
data : [
{ "id" : "1", "parent" : "#", "text" : "children" },
{ "id" : "2", "parent" : "1", "text" : "children 2" }
],
},
plugins : ['state']
}).on('state_ready.jstree', function() {
$('#jstree').on('select_node.jstree', function(e, data) {
alert(1);
});
});$('#jstree').jstree({
core : {
data : [
{ "id" : "1", "parent" : "#", "text" : "children" },
{ "id" : "2", "parent" : "1", "text" : "children 2" }
],
},
plugins : ['state']
}).on('state_ready.jstree', function() {
$('#jstree').on('select_node.jstree', function(e, data) {
//alert(1);jQuery(document).ready(function() {
// When a link is clicked, we redirect to href.
jQuery('[id^=menu-jstree-]').on("select_node.jstree", function (e, data) {
if (data.event)
document.location = data.instance.get_node(data.node, true).children('a').attr('href');
data.instance.deselect_node(data.node);
/*var href = data.node.a_attr.href;
document.location.href = href;*/
});
})