am almost there... need little more advice.  How to pass controller data to 
a javascript var?

here is the original example I copied from, which uses a text file as 
source.  Works perfect.

// Initialize Fancytree
$("#alexTree").fancytree({
checkbox: true,
selectMode: 3,
source: {url: "test-issue-NNN-alex_glaros.json"},
postProcess: function(event, data){
data.result = convertData(data.response);
},
select: function(event, data) {
window.open(data.node.data.alexLink, "_blank");
}
});

I take the exact same data from the text file and copy to controller

    json_list=[ { "alexLink": "http://example.com/";, "kind": "tasks#task", 
"id": "MTYwNzEzNjc2OTEyMDI1MzcwNzM6ODUwNjk4NTgzOjExMTkyODk2MjA", "etag": 
"\"4qyCALf1j510T_-I20NAMbUHF2k/LTEzNTgzMTMzODg\"", "title": "Task 01", 
"updated": "2015-04-23T19:25:44.000Z", "selfLink": 
"https://www.googleapis.com/tasks/v1/lists/MTYwNzEzNjc2OTEyMDI1MzcwNzM6ODUwNjk4NTgzOjA/tasks/MTYwNzEzNjc2OTEyMDI1MzcwNzM6ODUwNjk4NTgzOjExMTkyODk2MjA";,
 
"position": "00000000002147483647", "status": "needsAction" }, { 
"alexLink": "http://example.com/";, "kind": "tasks#task", "id": 
"MTYwNzEzNjc2OTEyMDI1MzcwNzM6ODUwNjk4NTgzOjg4ODk2MDI0MQ", "etag": 
"\"4qyCALf1j510T_-I20NAMbUHF2k/MTk0Mzk4OTY0\"", "title": "Children of Task 
01", "updated": "2015-04-27T15:26:40.000Z", "selfLink": 
"https://www.googleapis.com/tasks/v1/lists/MTYwNzEzNjc2OTEyMDI1MzcwNzM6ODUwNjk4NTgzOjA/tasks/MTYwNzEzNjc2OTEyMDI1MzcwNzM6ODUwNjk4NTgzOjg4ODk2MDI0MQ";,
 
"parent": "MTYwNzEzNjc2OTEyMDI1MzcwNzM6ODUwNjk4NTgzOjExMTkyODk2MjA", 
"position": "00000000002147483647", "status": "needsAction" }, { 
"alexLink": "http://example.com/";, "kind": "tasks#task", "id": 
"MTYwNzEzNjc2OTEyMDI1MzcwNzM6ODUwNjk4NTgzOjEwNzM4NjYzMw", "etag": 
"\"4qyCALf1j510T_-I20NAMbUHF2k/LTEyOTcyNTg1NA\"", "title": "Task 02", 
"updated": "2015-04-27T15:26:31.000Z", "selfLink": 
"https://www.googleapis.com/tasks/v1/lists/MTYwNzEzNjc2OTEyMDI1MzcwNzM6ODUwNjk4NTgzOjA/tasks/MTYwNzEzNjc2OTEyMDI1MzcwNzM6ODUwNjk4NTgzOjEwNzM4NjYzMw";,
 
"position": "00000000003500526173", "status": "needsAction" }, { 
"alexLink": "http://example.com/";, "kind": "tasks#task", "id": "id_101", 
"title": "node1.1", "parent": "id_100", "position": 
"000000000021474836472", "status": "needsAction" }, { "alexLink": 
"http://example.com/";, "kind": "tasks#task", "id": "id_103", "title": 
"node1.3", "parent": "id_100", "position": "000000000021474836474", 
"status": "needsAction" }, { "alexLink": "http://example.com/";, "kind": 
"tasks#task", "id": "id_100", "title": "node1", "position": 
"000000000021474836471", "status": "needsAction" }, { "alexLink": 
"http://example.com/";, "kind": "tasks#task", "id": "id_102", "title": 
"node1.2", "parent": "id_100", "position": "000000000021474836473", 
"status": "completed" } ]

Then I modify javascript in the view to accept data from controller instead 
of text file

this first version almost works

// Initialize Fancytree
$("#alexTree").fancytree({
checkbox: true,
selectMode: 3,
source:  {{=XML(json_list)}},
postProcess: function(event, data){
data.result = convertData(data.response);
},
select: function(event, data) {
window.open(data.node.data.alexLink, "_blank");
}
});

But I think it might need data to be in a javascript var.  Can anyone show 
me how to put in javascript var and where?  I don't think data ever makes 
it into the many var versions including one I tried below

    var AlexTreeData = $([{{=XML(json_list)}}]);
// Initialize Fancytree
$("#alexTree").fancytree({
checkbox: true,
selectMode: 3,
source: AlexTreeData,
postProcess: function(event, data){
data.result = convertData(data.response);
},
select: function(event, data) {
window.open(data.node.data.alexLink, "_blank");
}
});
});

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to