Issue 473: postProcess callback does not get called in initAjax
Status:  Fixed
Owner: ----
Closed:  Feb 2014
Reported by alga...@gmail.com, Jan 24, 2014
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 29, 2014
#1 alga...@gmail.com
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);
}
Jan 30, 2014
Project Member #2 moo...@wwwendt.de
(No comment was entered for this change.)
Status: Accepted
Labels: Milestone-Release1.2.6
Feb 5, 2014
Project Member #3 moo...@wwwendt.de
This issue was closed by revision r693.
Status: Fixed
Mar 14, 2014
Project Member #4 moo...@wwwendt.de
This issue was updated by revision r699.