Skip to content

Instantly share code, notes, and snippets.

@bigsan
Created January 26, 2010 16:48
Show Gist options
  • Save bigsan/286985 to your computer and use it in GitHub Desktop.
Save bigsan/286985 to your computer and use it in GitHub Desktop.
JavaScript: add asmx support to jstree 0.99
(functioin($) {
$.extend($.tree.datastores, {
"asmx": function() {
// borrow datastore from "json"
var asmxds = $.tree.datastores.json();
// override "load" function:
// 1. serialize input data into string through JSON.stringify
// 2. add "contentType" attribute to $.ajax call
asmxds.load = function(data, tree, opts, callback) {
if (typeof(data).toLowerCase() != "string" && window.JSON) {
data = JSON.stringify(data);
}
if(opts.static) {
callback.call(null, opts.static);
}
else {
$.ajax({
'type' : opts.method,
'url' : opts.url,
'data' : data,
'dataType' : "json",
'contentType': "application/json",
'success' : function (d, textStatus) {
callback.call(null, d);
},
'error' : function (xhttp, textStatus, errorThrown) {
callback.call(null, false);
tree.error(errorThrown + " " + textStatus);
}
});
}
};
return asmxds;
}
});
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment