fauzi28 / dynatree

Automatically exported from code.google.com/p/dynatree
0 stars 0 forks source link

postProcess callback does not get called in initAjax #473

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
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
        // http://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

Original issue reported on code.google.com by alga...@gmail.com on 24 Jan 2014 at 10:21

GoogleCodeExporter commented 8 years ago
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);
}

Original comment by alga...@gmail.com on 29 Jan 2014 at 11:21

GoogleCodeExporter commented 8 years ago

Original comment by moo...@wwwendt.de on 31 Jan 2014 at 7:17

GoogleCodeExporter commented 8 years ago
This issue was closed by revision r693.

Original comment by moo...@wwwendt.de on 6 Feb 2014 at 7:05

GoogleCodeExporter commented 8 years ago
This issue was updated by revision r699.

Original comment by moo...@wwwendt.de on 14 Mar 2014 at 4:49