Hi,
How can I use the json object (formatted as the jstree in core) to use in the search callback? More questions in comments inside the code below
Eg.
search: {
ajax: function(searchText, searchCallback){
$.ajax({
dataType: "json",
url: "blah blah url",
type: "POST",
data: {
//Some data to pass in ajax
},
success: function(data){
//This is the data received [{"id": "N1", "parent": "#", "text": "World", "type": "org"},{"id":
"N2", "parent": "N1", "text": "America", "type": "org"},{"id": "N3",
"parent": "N1", "text": "Asia", "type": "org"}]
//I understand and read in the docs to use an array of node id (without #) to pass in the search callback but it triggers multiple ajax request and it is slow. Why can't I just pass the json array like in the core callback (I've tried and it doesn't work)?
//Also how can I display "No results found" if there are no data passed? My tree does not do anything if I pass an empty array on search callback
var result, nodesToOpen;
result = ajaxDataFilter(data);
nodesToOpen = [];
//get only the id of nodes to open
_.each(result, function(record, index){
nodesToOpen.push(
record.id);
});
searchCallback.call(this, nodesToOpen);
}
});