Hi, Martin!
I was unable to create a tree based on previously created div. The
code I've tried is below (it's ripped out from the context but the
idea is clear). So when I try to get a root node I get an undefined
value. From the other side if I try to tie the tree to an existing div
everything goes just fine. Actually I've only tested this on Safari 3
Mac with dynatree 0.3 rc1.
this.popup = document.createElement('div'); // when I change this to
this.popup = $('#tree').get(0) evrthn's ok
this.popup.id = 'treeselect';
$(this.popup).css({
marginTop: this.select.offsetHeight +'px',
width: (this.select.offsetWidth) +'px',
});
$('#' +
this.popup.id).dynatree({
title: "",
rootVisible: true,
autoCollapse: true,
imagePath: Drupal.settings.treeSelect.imagePath,
onSelect: function(dtnode) { ts.onselect(dtnode); },
});
var rootNode = $('#' +
this.popup.id).dynatree("getRoot");
P.S. By the way the context of my problem is to create a tree based on
options of a select. CMSs sometimes generate a long selects with
'hierarchical' options inside which are not user-friendly at all. And
when you can only change templates but not the CMS code, the pretty
solution is to use such unobtrusive js.