Created
January 26, 2010 16:48
-
-
Save bigsan/286985 to your computer and use it in GitHub Desktop.
JavaScript: add asmx support to jstree 0.99
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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