Major problems with rename...

9 views
Skip to first unread message

toc

unread,
Dec 14, 2009, 8:08:09 PM12/14/09
to jsTree
Im having some problems with rename...My tree has some custom text
that appears at the start of each item - ideally I dont want it to be
editable, but failing that, I would like it (the custom text) to be
automatically added before any other text.

I have a 'onrename' callback that traps the rename, and I thought I
could just manually call rename:

var new_label = TREE_OBJ.get_text(NODE);

TREE_OBJ.rename(NODE,"<b>Custom text: "+new_label+"</b>");

On doing this, my browser get stuck in an endless loop. also the
bold style does not get applied.

any ideas?

toc

unread,
Dec 14, 2009, 9:48:40 PM12/14/09
to jsTree
Ah - obviously what is happening here is that calling 'rename' is
firing another 'onrename' event, and so on...

Still, I wouldn't mind the ability to customize just what gets
renamed, and how it does it.

vakata

unread,
Dec 16, 2009, 11:23:15 AM12/16/09
to jsTree
Hmmm, the set_text function is implemented in 1.0 which is not yet
released. So you'd have to modify the DOM yourself:

NODE.children("a:eq(0)").contents().filter(function() { return
this.nodeType == 3; })[0].nodeValue = "<b>Custom text: " +
TREE_OBJ.get_text(NODE) + "</b>";

Hope this helps till the next version is ready.
Cheers,
Ivan
Reply all
Reply to author
Forward
0 new messages