change the json_data ajax url from client side(javascript)

943 views
Skip to first unread message

Cybe...@gmx.de

unread,
Jan 4, 2011, 11:05:05 AM1/4/11
to jsTree
Hello,

I have the latest version of jstree and try to change the json_data
ajax url from client side(javascript) when a button is pressed before
I refresh the tree - so that the tree gets its data from a new url
when the button is pressed - how can I do that?

$("#demoTree").jstree({
"json_data": {
"ajax": {
"url": /test",
...


I did try:
$("#demoTree").json_data.ajax.url = "/test2";

$("#demoTree").jstree("refresh");

refresh works but the json_data.ajax is unknown.
Please help me....

GWinning

unread,
Jan 5, 2011, 8:09:47 AM1/5/11
to jsTree
Hello,

I was able to do it, but I'm not sure my way is correct. Without
thinking, I just called the same functiont hat I used to initially
populate the tree with the JSON with a URL built from variables:

$("#FolderTreeView").jstree({
"json_data" : {
"ajax" : {
"url" : myURL,
"success" : function (data) {alert('hi guys');}
}
},
"plugins" : [ "themes", "json_data","ui" ]
})

The onclick would set the global myURL variable to the desired URL.
It worked, but now that I see this post, I wonder if I'm doing it
"correctly" too.

rock_jack

unread,
Jan 10, 2011, 3:12:52 AM1/10/11
to jst...@googlegroups.com
I have the same problem

vakata

unread,
Jan 12, 2011, 12:48:16 PM1/12/11
to jsTree
You can use:

$.jstree._focused()._get_settings().ajax.url = "some/url";

or set the ajax.url option to a function - it will be invoked before
each request, and the return value will be used as the URL.

Kindest regards,
Ivan
Reply all
Reply to author
Forward
0 new messages