hColumns
hColumns copied to clipboard
Can't use the ajax example in the main demo page
Hello there, I hope that somedy have found a way to use an ajax call to use the file manager. At the end I need to load a first row of files then with some ajax call, load a new branch of the tree and so on..
As i can't use the example and havent figured out a way to use this correctly i'm trying to ask for you guys if you have a solution.. Thanks a lot, have a nice day.
Big Tata
Hi, this works for me:
$('#columns').hColumns({
nodeSource: function(node_id, callback) {
$.ajax({
dataType: "json",
url: "resource.php",
data: { node_id: node_id },
}).done(function(data) {
return callback(null, data);
}).fail(function() {
return callback("AJAX error");
});
}
});
Thanks a lot, i'll give it a go tonight and came back to you after :)
That ajax call did not work for me in the context of the same data as the demo, but this one did, where the server returns the same JSON as in the demo:
$('#columns').hColumns({
nodeSource: function(node_id, callback) {
$.ajax({
dataType: "json",
url: "/ajax",
data: { node_id: node_id }
}).done(function(data) {
if(node_id === null) {
node_id = 0;
}
if( !(node_id in data) ) {
return callback("Node not exists");
}
return callback(null, data[node_id]);
}).fail(function() {
return callback("AJAX error");
});
}
});