| Issue 473: | postProcess callback does not get called in initAjax | |
| 1 person starred this issue and may be notified of changes. | Back to list |
What steps will reproduce the problem?
1. Configure a dynatree with initAjax and postProcess callback with a simple console.log('YAY!')
2. Reload the page
3. Look at the empty console
I'm using jQuery 1.8.3 and jQuery UI 1.9.2.
Debugging with Firebug shows that options.postProcess in the ajax success callback (row 1834) is undefined:
---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8<
var options = $.extend({}, this.tree.options.ajaxDefaults, ajaxOptions, {
success: function(data, textStatus, jqXHR){
// <this> is the request options
// self.tree.logDebug("appendAjax().success");
var prevPhase = self.tree.phase;
self.tree.phase = "init";
// postProcess is similar to the standard dataFilter hook,
// but it is also called for JSONP
if( options.postProcess ){ <================================================= HERE
data = options.postProcess.call(this, data, this.dataType);
}
// Process ASPX WebMethod JSON object inside "d" property
// https://code.google.com/p/dynatree/issues/detail?id=202
else if (data && data.hasOwnProperty("d")) {
data = (typeof data.d) == "string" ? $.parseJSON(data.d) : data.d;
}
if(!$.isArray(data) || data.length !== 0){
self.addChild(data, null);
}
self.tree.phase = "postInit";
if( orgSuccess ){
orgSuccess.call(options, self, data, textStatus);
}
---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8< ---- 8<
Thanks for your work
Jan 30, 2014
(No comment was entered for this change.)
Status:
Accepted
Labels: Milestone-Release1.2.6
Mar 14, 2014
This issue was updated by revision r699. |
To fix the bug it should be enough to change: if( options.postProcess ){ data = options.postProcess.call(this, data, this.dataType); } in: if( self.tree.options.postProcess ){ data = self.tree.options.postProcess.call(this, data, this.dataType); }