dragged node should be copied with change of its style

53 views
Skip to first unread message

Zoran Jeremic

unread,
Jun 18, 2010, 12:18:23 PM6/18/10
to jsTree
Hi Ivan,

I switched to jsTree 1.0 recently. I have two trees. User can
drag'n'drop from the left to right tree. However, I want to override
default drag'n'drop, so the moved node should actually not moved from
left tree, but to copy it and change it's font color, or to make it's
background gray both in left and right tree. Then user should have
option in context menu to rollback for each new node.

Can you give me some suggestions how to make this work?

Zoran

vakata

unread,
Jun 19, 2010, 3:43:24 PM6/19/10
to jsTree
Hi,

just use the latest commit and set "always_copy" to "multitree" (the
CRRM plugin - look at the docs)
As for changing the color - just bind to the move_node event:

$("#tree_container").bind("move_node.jstree", function (e, data) {
data.rslt.o.css("color","red");
data.rslt.oc.css("color","red"); // check which works for you - this
or the above line
});

As for the rollback - save the rollback you are provided in the above
function: data.rlbk

Use that whenever you want. For example you can store it on the node
itself (using jQuery's data function) and when the user shows the
context menu on that node - display the option, note that it will
bring back all the changes since the node was moved.


Cheers,
Ivan

Zoran Jeremic

unread,
Jun 20, 2010, 7:47:14 AM6/20/10
to jsTree
Hi Ivan,

I couldn't solve this.
If I use the latest jquery.jstree.js 178 from SVN, the tree is not
initialized at all. If I use a stable one v1.0.rc, then these
functions does not work like it should be.
For example,
$("#basic_html").jstree({
"json_data" : {
"data" : leftTreeIniData

},
"crrm":{
"move" : {
"always_copy" : "multitree"
}
},
this behave the same if the value is multitree or true. The node is
copied inside the tree, but when I try to copy from one tree to
another, the node is just moved.

And this code:
$("#basic_html").bind("move_node.jstree",
function (event,data){
data.rslt.oc.css("color","red");
$('#dialog').dialog('open');
}
);
It just open dialog specified at the second line, but there is no
change in color.
I suppose that this is changed in the later release, but as I told you
the latest one does not work.

Zoran

Ivan Bozhanov

unread,
Jun 20, 2010, 9:18:31 AM6/20/10
to jstree
Hmm, this is very odd, can you show me a live demo, or paste your
config, as with my working copy the tree works just fine ... it is
very odd that the tree is not shown at all... I will fix this as soon
as I can reproduce it, so please show me your config and I will apply
a fix and commit right away.

Cheers,
Ivan

> --
> You received this message because you are subscribed to the Google Groups "jsTree" group.
> To post to this group, send email to jst...@googlegroups.com.
> To unsubscribe from this group, send email to jstree+un...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/jstree?hl=en.
>
>

Zoran Jeremic

unread,
Jun 20, 2010, 9:45:38 AM6/20/10
to jsTree
Hi Ivan,

I can't show you a live demo, as I can't host it. What I can is to
send you a separate file or a I can also share the whole project.

Here is a js file with both trees configuration
http://zoranjeremic.org/files/intelLEO.LPC.createlearninggoal.js

BTW: I have also tried several other versions of jquery.jstree.js from
SVN(all were created in June), and none of them have worked for me.

Zoran

On Jun 20, 3:18 pm, Ivan Bozhanov <ivan.bozha...@gmail.com> wrote:
> Hmm, this is very odd, can you show me a live demo, or paste your
> config, as with my working copy the tree works just fine ... it is
> very odd that the tree is not shown at all... I will fix this as soon
> as I can reproduce it, so please show me your config and I will apply
> a fix and commit right away.
>
> Cheers,
> Ivan
>

Ivan Bozhanov

unread,
Jun 20, 2010, 9:48:15 AM6/20/10
to jstree
I did not have the time to properly test - but try leaving only one
datasoure - either html_data or json_data (your plugins config option)
that will do it.

Cheers,
Ivan

Zoran Jeremic

unread,
Jun 20, 2010, 10:13:15 AM6/20/10
to jsTree
Hi Ivan,

This solved the problem. Now I had a always copy function that works
fine, but the other option with change of style doesn't work.
data.rslt.o.css("color","red");
does not have any effects

data.rslt.oc.css("color","red");
fires error in firebug about non existing function

Do I have to add some plugin for this?
Zoran

On Jun 20, 3:48 pm, Ivan Bozhanov <ivan.bozha...@gmail.com> wrote:
> I did not have the time to properly test - but try leaving only one
> datasoure - either html_data or json_data (your plugins config option)
> that will do it.
>
> Cheers,
> Ivan
>

Ivan Bozhanov

unread,
Jun 20, 2010, 10:32:20 AM6/20/10
to jstree
Sorry about that - inside the move_node event try using
console.log(data) to see what the object contains ... if you are using
the latest commit and a copy is made there should be both o and oc
properties ... to modify the color use:
data.rslt.o.children("a").color(...

Cheers,
Ivan

Reply all
Reply to author
Forward
0 new messages